Skip to content

u/slipperydippery

In this archive from Aug 2012 to Mar 2023

7
posts
50
comments
0
media
120
score
1 saved before deletion

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

1 points

So if I understand it correctly:

  • 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.

Thanks for helping me clear it up!

1 points

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 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
1 points

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?

DB_DATABASE=nothomesteadbutsomethingelse
2 points

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) {

or something like that.

1 points

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!

1 points

Thanks for the response!

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 guess I could solve my js problem as follows:

this.allpodcasts.filter(function(thispodcast){
    return this.user.subsciptions.podcasts.filter(function(thissubscription){
        return thispodcast.id == thissubscription.podcast.id;
    }).length;
});
1 points

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.

4 points

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.

1 points

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.

1 points

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?

10 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.