The advantage of this is that the user gets to keep input even if they log out half way through the form.
The disadvantage is that you have to manage these incomplete models. You could try an is-complete flag in the database, or perhaps step-complete flag which tracks which steps have been completed.To keep your database clean you should probably refactor this completeness tracker to another table.
But likely your form is gathering information that goes beyond one model/table, so your partially filled forms will need a table for themselves. This is ok, but kind of clunky. If you want to update your form, you now also have to update your table, and now have to manage the data currently in there one way or the other.
In the end it feels like a session with extra steps, but it is more robust with regards to not losing the user's input - if that's something that is desired
I read somewhere that extending a pure abstract class could help to indicate a logical relationship - but I guess that's more of a programmer preference question.
When a class implements an interface, the interface's defined methods are now also bound to the class.
When the class doesn't implement the defined method(s), PHP considers it an abstract class because it doesn't have all of it's defined methods implemented.
Even if a class has none of its defined methods implemented, it will be considered as abstract and not an interface because an interface is not a class.
I was thrown off by the error. I was expecting something along the lines of "Hey, you're not conforming to your interface". I see that if I skip the MyAbstract class, and have MyClass implement MyInterface directly, I get the same error.
I still find it weird. Is an interface a modified abstract method behind the scenes? If I have a method without a body in a plain class, I get a different error.
Fatal error: Non-abstract method Slipperydippery\Test::func() must contain body
Yeah, I wouldn't delete create_users_table and create_password_resets_table because they are very useful. Unless you're not going to be working with user's or Laravel's auth system.
Are you creating different databases for each project? And adding that to your .env?
I would try working the other way. Start by commenting out all migrations except the default create_users_table and create_password_resets_table. See if that migrates.
If that works, add buat_table_buku back in, try to migrate.
If that works, add table_buku back in, etc.
I think that you'll find that in one of the newer migration files you have:
Schema::create('users', function (Blueprint $table) {
while it should be
Schema::create('buat', function (Blueprint $table) {
Nice, there are a few thing in here I didn't know and that will come in handy. I just don't know if I'll ever feel comfortable touching my parent child relationship...
I just ran the analyzer on a project I'm working on and got some useful and informative comments to dig through. A decent number of the comments were things that I had been thinking about (should all my controllers only ever contain CRUDdy methods, should I put my API routes in the routes/api.php even though I'm only ever accessing them locally).
But there's also a couple of things that I hadn't thought through just yet, so that should result in an improvement of my code and coding skills, so thanks!
Oh wow, I didn't know about .map! That's a really elegant solution, and yeah, this does push the concept of "pivot as Model" to an overall positive change (for me).
Your method is indeed what I am trying to emulate: A subscriptionsendpoint (for me that would indeed be /user/{user}/subscription from my nested resource Route::resource('user.subscription', 'UserSubsciptionsController');). That's been working quite will, except on the front end. I'm just so used to a bucket of podcast's, and now it's a bucket of subscription's, each containing a podcast.
I don't think your problem is that web.php is too big at all. I think the issue is that your controller methods are overly complicated. If you create semantically better (and simpler!) controllers, your web.php will become semantically clearer and easier to manage.
Currently you have only 2 controllers: BlogController and CmsController. I understand the instinct to do this, but common practice (and the way Laravel is set up) is to have your Controllers control a Model. And since indexing/storing/creating Blog and Cms Model's don't make much sense (and you probably don't have those models in your project), I'd much rather see UsersController, PostsController, Pagesontroller, CommentsController, UserPostsController, etc. Here, indexing/storing/creating/etc Users, or Posts makes a lot of sense. Also, having the controllers freed up from the context of being either part of the CMS or part of the Blog will allow your controllers to be much more versatile (especially once you're working with API calls).
Try doing this: whenever you create a Controller, for example PostsController, create it with php artisan make:controller PostsController --resource, and try to stick to the provided methods only. Now, for your routes in web.php you can be explicit:
Route::get('/post', 'PostsController@index')->name('post.index');
Route::get('/post/{post}', 'PostsController@show')->name('post.show');
etc.
Or you could you could use
Route::resource('post', 'PostsController');
Which will automatically create all 7 routes corresponding with your 7 controller methods. This will greatly increase the readability and manageability of your web.php.
-- next steps --
Now, if you want to list all posts by a certain user, that won't fit in either PostsController or UsersController, but you can create a new controller: UserPostsController(as a resource), and now you have acces to:
Route::get('/user/{user}/post', 'UserPostsController@index')->name('user.post.index');
or
Route::resource('user.post', 'UserPostsController');
And Route::resource here will automatically generate nested routes to your controller methods.
That makes sense. My primary issue is indeed with the initial page load, and fetching of data at that point.
I was just listening to the full stack podcast, and Taylor Otwell was saying how he likes create a lot of controllers instead of bloating them. As soon as he's past the restful verbs it's time to move functionals to a new controller.
Ah, thanks! I hadn't thought about the option of passing the data as variables. That could make my Vue components a lot more manageable than passing branches of branches within a single mega array. Plus, I like the idea of having components responsible for their own data.
I'll see if I I'd I can get that to work in a meaningful way, and otherwise I still might go for the mega array. And just create a new controller for gathering all that data.
Ah, thanks! This is my first big project with Vue, and when I started I didn't think it would be that big. So I hadn't considered Vuex earlier, but I guess it's about time I did!
I'm not going to read 100+ books in 2016. Even the author is only reading a maximum of 12 books this year, and has only "at least started a couple of chapters" in the "majority of the books".
I know it's fun to have a decked out design library. But I'd rather have a few really solid and personal recommendations than this random list of "classics".
Early worm
The advantage of this is that the user gets to keep input even if they log out half way through the form.
The disadvantage is that you have to manage these incomplete models. You could try an is-complete flag in the database, or perhaps step-complete flag which tracks which steps have been completed.To keep your database clean you should probably refactor this completeness tracker to another table.
But likely your form is gathering information that goes beyond one model/table, so your partially filled forms will need a table for themselves. This is ok, but kind of clunky. If you want to update your form, you now also have to update your table, and now have to manage the data currently in there one way or the other.
In the end it feels like a session with extra steps, but it is more robust with regards to not losing the user's input - if that's something that is desired
Oh wow, thanks for the extensive answer!
Thanks for the clarification!
I read somewhere that extending a pure abstract class could help to indicate a logical relationship - but I guess that's more of a programmer preference question.
Thanks again!
So if I understand it correctly:
Thanks for helping me clear it up!
But the abstract class is declared on my abstract class, so why is it giving this error?
Oh my bad. Thanks for pointing that out.
I was thrown off by the error. I was expecting something along the lines of "Hey, you're not conforming to your interface". I see that if I skip the
MyAbstractclass, and haveMyClassimplementMyInterfacedirectly, I get the same error.I still find it weird. Is an interface a modified abstract method behind the scenes? If I have a method without a body in a plain class, I get a different error.
https://laravel-news.com/laravel-5-4-key-too-long-error
Yeah, I wouldn't delete create_users_table and create_password_resets_table because they are very useful. Unless you're not going to be working with user's or Laravel's auth system.
Are you creating different databases for each project? And adding that to your .env?
I would try working the other way. Start by commenting out all migrations except the default create_users_table and create_password_resets_table. See if that migrates.
If that works, add buat_table_buku back in, try to migrate.
If that works, add table_buku back in, etc.
I think that you'll find that in one of the newer migration files you have:
while it should be
or something like that.
Maybe like so?
php artisan migrate:resetcomposer dump-autoloadphp artisan migrateNice, there are a few thing in here I didn't know and that will come in handy. I just don't know if I'll ever feel comfortable touching my parent child relationship...
Ah, of course. And that seems like a cleaner option than most of the ones I mentioned.
33eE wee 3#e3eE3E333333 u zee U 3E3# 33e
Thanks for making this free!
I just ran the analyzer on a project I'm working on and got some useful and informative comments to dig through. A decent number of the comments were things that I had been thinking about (should all my controllers only ever contain CRUDdy methods, should I put my API routes in the routes/api.php even though I'm only ever accessing them locally).
But there's also a couple of things that I hadn't thought through just yet, so that should result in an improvement of my code and coding skills, so thanks!
The soundtrack is amazing. "Hans Zimmer knows what the world sounds like". Just listening to the soundtrack puts me right in that world.
... As long as it's on a playlist that skips the Elvis songs
Oh wow, I didn't know about .map! That's a really elegant solution, and yeah, this does push the concept of "pivot as Model" to an overall positive change (for me).
Thanks!
Whoops, you're right, I changed it in the post
Thanks for the response!
Your method is indeed what I am trying to emulate: A
subscriptionsendpoint (for me that would indeed be/user/{user}/subscriptionfrom my nested resourceRoute::resource('user.subscription', 'UserSubsciptionsController');). That's been working quite will, except on the front end. I'm just so used to a bucket ofpodcast's, and now it's a bucket ofsubscription's, each containing a podcast.I guess I could solve my js problem as follows:
I don't think your problem is that web.php is too big at all. I think the issue is that your controller methods are overly complicated. If you create semantically better (and simpler!) controllers, your web.php will become semantically clearer and easier to manage.
Currently you have only 2 controllers:
BlogControllerandCmsController. I understand the instinct to do this, but common practice (and the way Laravel is set up) is to have your Controllers control a Model. And since indexing/storing/creatingBlogandCmsModel's don't make much sense (and you probably don't have those models in your project), I'd much rather seeUsersController,PostsController,Pagesontroller,CommentsController,UserPostsController, etc. Here, indexing/storing/creating/etcUsers, orPostsmakes a lot of sense. Also, having the controllers freed up from the context of being either part of the CMS or part of the Blog will allow your controllers to be much more versatile (especially once you're working with API calls).Try doing this: whenever you create a Controller, for example
PostsController, create it withphp artisan make:controller PostsController --resource, and try to stick to the provided methods only. Now, for your routes in web.php you can be explicit:Or you could you could use
Which will automatically create all 7 routes corresponding with your 7 controller methods. This will greatly increase the readability and manageability of your web.php.
-- next steps --
Now, if you want to list all posts by a certain user, that won't fit in either
PostsControllerorUsersController, but you can create a new controller:UserPostsController(as a resource), and now you have acces to:And
Route::resourcehere will automatically generate nested routes to your controller methods.That makes sense. My primary issue is indeed with the initial page load, and fetching of data at that point.
I was just listening to the full stack podcast, and Taylor Otwell was saying how he likes create a lot of controllers instead of bloating them. As soon as he's past the restful verbs it's time to move functionals to a new controller.
Wow, hardcore! Thanks for that, it looks super useful. I'm on the road now, but will take a good look at it when I'm at a workstation
Ah, thanks! I hadn't thought about the option of passing the data as variables. That could make my Vue components a lot more manageable than passing branches of branches within a single mega array. Plus, I like the idea of having components responsible for their own data.
I'll see if I I'd I can get that to work in a meaningful way, and otherwise I still might go for the mega array. And just create a new controller for gathering all that data.
Ah, thanks! This is my first big project with Vue, and when I started I didn't think it would be that big. So I hadn't considered Vuex earlier, but I guess it's about time I did!
I'm not going to read 100+ books in 2016. Even the author is only reading a maximum of 12 books this year, and has only "at least started a couple of chapters" in the "majority of the books".
I know it's fun to have a decked out design library. But I'd rather have a few really solid and personal recommendations than this random list of "classics".
...and three books by Stephen Hawking?