Member Since 5 Years Ago
2,195 experience to go until the next level!
In case you were wondering, you earn Laracasts experience when you:
Earned once you have completed your first Laracasts lesson.
Earned once you have earned your first 1000 experience points.
Earned when you have been with Laracasts for 1 year.
Earned when you have been with Laracasts for 2 years.
Earned when you have been with Laracasts for 3 years.
Earned when you have been with Laracasts for 4 years.
Earned when you have been with Laracasts for 5 years.
Earned when at least one Laracasts series has been fully completed.
Earned after your first post on the Laracasts forum.
Earned once 100 Laracasts lessons have been completed.
Earned once you receive your first "Best Reply" award on the Laracasts forum.
Earned if you are a paying Laracasts subscriber.
Earned if you have a lifetime subscription to Laracasts.
Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.
Earned once you have achieved 500 forum replies.
Earned once your experience points passes 100,000.
Earned once your experience points hits 10,000.
Earned once 1000 Laracasts lessons have been completed.
Earned once your "Best Reply" award count is 100 or more.
Earned once your experience points passes 1 million.
Earned once your experience points ranks in the top 50 of all Laracasts users.
Earned once your experience points ranks in the top 10 of all Laracasts users.
Replied to How To Access Helper Method In Laravel By Vuejs
You cannot access a PHP method in VueJS... One runs on the server, one runs in the browser.
Either you pass data from Laravel into your blade and then pass it to VueJS or you can get data from the server via an AJAX call.
Replied to Notify Users That A New Post Has Been Published
$users = User::whereHas('categories')->with(['categories' => $callback])
->where('email_updates', 1)->get();
You have to put the category condition into the "whereHas" too :) Right now you're saying "give me users that have categories. And for those user also load the categories with this specific condition".
$users = User::whereHas('categories', function ($query) use ($topicCategory) { $query->where('id', $topicCategory); })->with(['categories' => $callback])
->where('email_updates', 1)->get();
Awarded Best Reply on Is It A Good Practice To Add Custom Verbs To Policies?
Of course that's no problem. The base logic only adds the base functionality - CRUD. But your business logic probably has more besides that in order to create value for your customers so you also need to extend the available base functionality.
Replied to How To Update Specific Filed According To A Condition?
Just move the array out of the method call.
$newData = [
'company_name' => $request['company_name'],
...
];
if (!empty($imageName)) {
$newData['company_logo'] = $imageName;
}
Company::find($id)->update($newData);
Replied to Is It A Good Practice To Add Custom Verbs To Policies?
Of course that's no problem. The base logic only adds the base functionality - CRUD. But your business logic probably has more besides that in order to create value for your customers so you also need to extend the available base functionality.
Replied to Unexpected Redirect To Login
Sounds like you lose your session somewhere in between the requests. What session driver do you use? Do you have a session()->flush() somewhere in a middleware maybe?
Replied to How To Become A Professional Laravel Developer
Technically? Find someone who pays you to develop something with Laravel for them. That's the definition of "professional".
But I guess you mean a "good" developer?
Exactly as @chaudigv said. Practise and don't get discouraged. Create a hobby project for yourself to see what it's about and what things you can use.
Replied to Retrieving A Loaded Relationship But Do Not Hit Database If Missing
relationLoaded shouldn't actually hit the DB. Are you sure about that one, that the DB Query comes from this part?
Replied to All Properties Of The $request Are A String Type !
https://laracasts.com/discuss/channels/general-discussion/handling-formdata-null-string
That should be the same problem :) The problem is FormData and axios, not on the Laravel side.
Awarded Best Reply on Similar Question: Trying To Get Property 'p_name' Of Non-object
hasMany returns a collection of items, not a single item. And a collection doesn't have the "p_name" attribute. You need to select a specific product from that collection or use a different kind of relationship (hasOne for example).
Replied to Similar Question: Trying To Get Property 'p_name' Of Non-object
hasMany returns a collection of items, not a single item. And a collection doesn't have the "p_name" attribute. You need to select a specific product from that collection or use a different kind of relationship (hasOne for example).
Replied to Return Redirect() Doesn't Redirect To Desired Page
You should check out the internal Laravel validation system :) It does exactly what you need (I think) and makes your controller a lot easier to read and understand. And for custom logic you can also create your own rules to validate a value.
Awarded Best Reply on Return Redirect() Doesn't Redirect To Desired Page
You return a redirect from another method. If you want to stop the flow you need to return from your controllermethod too. Otherwise you return the redirect but it just vanishes since you don't save it anywhere
Replied to Return Redirect() Doesn't Redirect To Desired Page
You return a redirect from another method. If you want to stop the flow you need to return from your controllermethod too. Otherwise you return the redirect but it just vanishes since you don't save it anywhere
Replied to Mail Markdown Messages - Invalid Argument Supplied For Foreach()
Hahaha, happens to everybody! I've spent many hours before to find that comma that shouldn't be there etc :)
Awarded Best Reply on Mail Markdown Messages - Invalid Argument Supplied For Foreach()
$this->$services = $services;
You have an $ after your -> :)
Replied to How To Get The Last Data Of The Day For A Week
You mean something like this?
Data::whereBetween('created_at', [now()->subWeek()->startOfDay(), now()->subWeek()->endOfDay()])->orderBy('created_at', 'DESC')->first();
This would give you only the data from the same day last week (so on thursday it would give you last weeks data from thursday), order that by date descending (so the latest would come first) and then returns the first one (so the latest one).
Replied to Mail Markdown Messages - Invalid Argument Supplied For Foreach()
I think public attributes of the Mailable are by default accessible inside the view if I remember correctly.
Replied to Testing The Relationship Opun Creating A Model In Laravel
If your database is empty during tests you can just check if there is one row inside your user_vendor table after executing the call.
Otherwise you can just get the user from the database with Eloquent like you usually would. It's the same database in your test and your controller :)
Replied to Mail Markdown Messages - Invalid Argument Supplied For Foreach()
$this->$services = $services;
You have an $ after your -> :)
Awarded Best Reply on How Can I Pass Get() Link In Laravel Controller
You mean you need to send a request to that URL? You can use something like Guzzle to send requests but the "get" function doesn't exist in PHP.
Replied to How Can I Pass Get() Link In Laravel Controller
You mean you need to send a request to that URL? You can use something like Guzzle to send requests but the "get" function doesn't exist in PHP.
Replied to Larastan / Double ?>
True, that can definitely be a bitch :D Unfortunately I don't know a tool / solution that can do it already
Replied to Laravel- Blade How To Output HTML Tag In Double Curly Braces?
Use unfiltered output if you're sure about the source:
{!! !!}
Replied to Larastan / Double ?>
It's not necessarily a bug since all you're saying is "alrighty, PHP stops here, everything from here on out is HTML". So you would probably have a random "?>" show up on your page somewhere
Replied to Production Server Frequently Facing Memory Issue.
PHP has memory on a "per request" basis... So just because your user is logged in and does stuff doesn't mean he / she is piling on memory because the garbage collector usually cleans it up in between. Same with images - while uploading they will be saved on the hard disk but you might have them in memory if you do other stuff for a short time (like resizing etc).
I've had a similar problem and saw that there is a php option if you are using php-fpm. See this thread: https://stackoverflow.com/questions/29608292/what-is-pm-max-children-and-pm-max-requests
Basically it says after how many requests a PHP process should be killed (and restarted) which would free up all the memory. I didn't have a value there so it would just sloooowly creep up bit by bit until it crashed. Currently I have a value of 500 in there (i think).
Replied to Counting Amount Of Products In Category Not Working In Laravel
First of all: Don't declare functions in blade!
Second:
Of course it can be done. Problem might more be "How to do it with good performance" ;-)
Multiple ways I could think of:
Write logic, that calculates the number of products "on the fly" (so live, as soon as you need it). This might be the most dynamic but of course also the most performance costly. Maybe in your usecase it's possible to use some caching here and cache the result for a couple of minutes to reduce the load.
Save the number of products for each category in the database. Then there is the question of when to update that number. One possibility would be to update it every time a product is added / removed / changes categories. This would probably perform a lot better but it might be easier to product bugs if you forget to call that update method somewhere.
Replied to Class 'Hexters\CoinPayment\CoinPayment' Not Found
Have you tried
composer dump-autoload
?
Replied to Accessor Not Working
What is happening instead? Do you still get 1 / 0 as value?
And can you show where you are using it?
Replied to Sort Posts With "Featured" Posts First
I'm not sure what your question is exactly?
If you have a simple field in the database I would order it in the database, so simply use two "orderBy" clauses.
Replied to Undefined Index: Questionid
Don't use $_POST... use the laravel tools.
request('questionid')
For example like that.
Replied to How To Allow Users Post Annoymous
Add a column "is_anonymous" to your posts table and when you output the username check for that column. If it's true -> display anonymous... otherwise display username.
Awarded Best Reply on Prebuilt Software Solution
That is exactly the point of Laravel... It brings a lot of commonly used functionality to the table and a lot of other functionality can be added with packages (also lots of "official" Laravel packages by the Laravel team).
Replied to General Error: 1364 Field 'name' Doesn't Have A Default Value
Although... apparently nothing is added to the query so that shouldn't be it since your password is hardcoded in the factory.
Do you maybe have another factory that accidentally has the User::class as a model?
Replied to General Error: 1364 Field 'name' Doesn't Have A Default Value
I think the faker "name" is an attribute, not a method (though it might be both - just jumped out at me :)).
So $this->faker->name,
Replied to View In Browser Link For Emails
I have most certainly not and I'm now very embarassed about it! That sounds like a great solution, thank you :D
Started a new Conversation View In Browser Link For Emails
Hey,
I'm currently working on some emails in a project (daily, weekly summaries of what has happened, stuff like that) and am thinking about how to best implement a "View this email in browser" link there in case the users have an old email program or just get text emails.
I know the "rendering a mailable as view" feature so that part is not my question. But I'm a little stumped about how to implement the - let's call it "state".
For example the daily summary summarizes changes that happened since the last reminder in the last 24hours (duh). So the email is created quite dynamically with those changes and I need the dynamic data of that email somewhere (since it's different for every user).
My thoughts so far were:
But number 1 would bloat the DB quite a bit and number 2 is a very big development and maintenance overhead.
Has anyone ever implemented a feature like that and could share some learnings?
Thank you
Replied to Http 500 Error When I Try Post Request
The method is called "Route::post" (small letters) but not sure if that would be the problem. Can you check the log file for the actual error message? (or turn on APP_DEBUG=true in the .env file and check the result of the POST request)
Replied to VUE Is Regret.
How about you show a project with jquery first? ;)
We don't need to convince you here... if you don't want to use it - use something else. It's that easy.
Awarded Best Reply on Symfony\Component\Routing\Exception\RouteNotFoundException
If you use redirect()->route() you need to pass the name of the route, not the actual URL... try redirect()->to($link) (I think, maybe it's url())
Replied to Symfony\Component\Routing\Exception\RouteNotFoundException
If you use redirect()->route() you need to pass the name of the route, not the actual URL... try redirect()->to($link) (I think, maybe it's url())
Replied to Split Seeder Into Multiple Seeders - Same Table
You can do whatever you want in a seeder. It's only a class that gets called, all the logic comes from you.
You could have a CitiesGermanySeeder and a CitiesFranceSeeder (for example) and then have a CitySeeder class that calls the other two...
Awarded Best Reply on TDD :Error: Call To Undefined Method Tests\Feature\ProjectTasksTest::signIn()
You called your method "singIn"
Replied to TDD :Error: Call To Undefined Method Tests\Feature\ProjectTasksTest::signIn()
You called your method "singIn"
Replied to Counting The Active Jobs Only With Jobs_count From Another Table
maybe orderBy('active_jobs_count'...)?
Awarded Best Reply on Target Class [Illuminate\Auth\Middleware\adminpermission] Does Not Exist.
You need to use the correct namespace for your middleware. Hopefully you haven't created the adminpermission file in the vendor folder? So your namespace can't start with Illuminate\ :)
Replied to Target Class [Illuminate\Auth\Middleware\adminpermission] Does Not Exist.
You need to use the correct namespace for your middleware. Hopefully you haven't created the adminpermission file in the vendor folder? So your namespace can't start with Illuminate\ :)