0 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.
Awarded Best Reply on How To Use Helper Function Directly In Blade In Laravel 6
@nafeeur10 I don't know exactly how did you register your helper.
Follow this document. It may help you.
https://medium.com/@razamoh/create-own-custom-helper-functions-classes-in-laravel-e8d2f50ff38
Replied to How To Use Helper Function Directly In Blade In Laravel 6
@nafeeur10 I don't know exactly how did you register your helper.
Follow this document. It may help you.
https://medium.com/@razamoh/create-own-custom-helper-functions-classes-in-laravel-e8d2f50ff38
Replied to What Technology To Use For A New Project?
@new-2-lara It always depends on your preferences. As of my understanding from your points, you can either choose wordpress (where you don't have to write code literally) OR use laravel where you could have a lot of flexibility for implementation.
Side Note: For using laravel you may need good knowledge of PHP (OOP).
Replied to Collection Replace ?
@ajvanho I guess you don't need to use collection here if it is an array. You can try this-
$lists = [
"key" => "7beqbabdHqdd3NMZ",
"attributes" => [
"url" => "GitHub",
"name" => "https://github.com/foo"
]
];
$replacedValues = [
"name" => "GitHub",
"url" => "https://github.com/foo",
];
$finalOutput = array_replace($lists, $replacedValues);
Replied to Collection Replace ?
@ajvanho Have you tried replace()
?
Check here: https://laravel.com/docs/8.x/helpers#method-fluent-str-replace
Replied to Get User Phone Number Using Wechat API
@jkrantz It seems it's possible. Have you checked this post? https://programmersought.com/article/66685893412/
Replied to How I Reflector My Code
@austinbryan Welcome to the Laravel World.
Honestly, as long as your code works, there is nothing wrong with that. But there are a lot of ways to improve your code. I believe it's all about fundamental parts.
I would recommend you to watch this series.
Awarded Best Reply on Create Internal Links On Website
@mbo You may not get the exact plugin on Laravel.
But what I suggest you that, since you know already what to build is just build from the sketch. That will help you to improve the knowledge!
Replied to Can I Do A Preg_match_all With Collection ?
@untymage If it is the collection, what if you use get()->each()
, then pass the regular expression inside the closure in each()
method?
Awarded Best Reply on Get Attributes From Image File
@david19 If you want to get the size of the file after uploading, I guess the easiest way to do that is-
$request->file('file')->getSize();
Replied to Get Attributes From Image File
@david19 If you want to get the size of the file after uploading, I guess the easiest way to do that is-
$request->file('file')->getSize();
Replied to Create Internal Links On Website
@mbo You may not get the exact plugin on Laravel.
But what I suggest you that, since you know already what to build is just build from the sketch. That will help you to improve the knowledge!
Awarded Best Reply on How Do You Test A Function That Returns A Generator?
@kevdev Yes, that's what I mean.
However, if you need to test implicitly, then you can follow this discussion: https://stackoverflow.com/questions/41343279/mocking-a-function-that-returns-a-generator-in-php-with-phpunit-phake
Replied to The Specified Value Cannot Be Parsed, Or Is Out Of Range In Vue
@ifrit probably it's because of mismatching the type of the value? Check this: https://stackoverflow.com/questions/63797379/the-specified-value-nan-cannot-be-parsed-or-is-out-of-range
Replied to Calculating Subtotal
@glitter grace What if you add an another variable called sub_total
and then return this?
<script>
export default{
props: [],
data(){
return {
products: [],
product_unit: null,
product_price: null,
sub_total: null,
}
},
computed:{
calculateAmount(){
this.sub_total = this.product_unit * this.product_price;
},
subTotal(){
return this.sub_total;
}
},
methods: {
getProducts(){
axios.get(`/api/product/all`).then(response => {
this.products = response.data.products;
});
}
},
mounted() {
this. getProducts();
}
}
</script>
Replied to Can Anyone Explain Me Why It Returns This Output?
@prince69 Probably you can use lazyload.
$user_order = auth()->user()->load('orders.orderFoodItems.price');
if ($user_order->count()) {
return response()->json($user_order, 200);
}
Replied to Nested Relationship To Match Column Of Base Modal
@deekshith Have you just used get()
instead of using first()
?
$registeredCourse = UserRegisteredCourse::where('course_id',$test->course_id)->where('user_id',$test->user_id)->get();
Replied to Nested Relationship To Match Column Of Base Modal
@deekshith I am not so sure what exactly you want to achieve, but for nesting relationship, you need to use .
notation.
For example-
->with('relationship.nestedRelationship')
Ref: https://laravel.com/docs/8.x/eloquent-relationships#nested-eager-loading
To optimize uses of with()
, you can use like that-
OfflineConvertedTest::with([
'userdet',
'slotdet',
'coursedet',
'centerdet',
])->whereIn('test_id',$getTestids)
->get();
Sidenote: It's not related to solving your issue.
Replied to How To Store Rate Field In Pivot Table In Laravel
@coder72 Make sure that the rate
column is fillable in the model.
Besides, I notice that, you have a type. Probably its array('rate' => $ite)
insead of array('rate' => $item)
.
$user->items()->sync($request->item, array('rate' => $ite));
Replied to How Do You Test A Function That Returns A Generator?
@kevdev Yes, that's what I mean.
However, if you need to test implicitly, then you can follow this discussion: https://stackoverflow.com/questions/41343279/mocking-a-function-that-returns-a-generator-in-php-with-phpunit-phake
Awarded Best Reply on How To Make Custom Login Only For Admin In Laravel?
@ihprince Just apply a condition insider if.
if (Auth::attempt($credentials)) {
if(Auth::user()->is_admin !== 1){
// Now redirect to the user's login page
}
// Now redirect to the admin panel
}
Replied to How To Make Custom Login Only For Admin In Laravel?
@ihprince Just apply a condition insider if.
if (Auth::attempt($credentials)) {
if(Auth::user()->is_admin !== 1){
// Now redirect to the user's login page
}
// Now redirect to the admin panel
}
Replied to How Do You Test A Function That Returns A Generator?
@kevdev If you don't need to cross-check with the exact data return type, then you may check the instanceOf
. Check whether it returns the right instance or not.
Replied to Converting From CST To UTC
@jmurphy1267 Since you have mentioned using it on the frontend side, why you do not use Moment JS?
Just get some idea from this discussion and apply it in a reverse way. https://stackoverflow.com/questions/34361866/how-do-i-convert-utc-gmt-datetime-to-cst-in-javascript-not-local-cst-always
Replied to Site 500 Error, Newbie Needs Help
@justaskkath Just in real quick you can enable APP_DEBUG=true
in .env
file to check what error you get. Note It's not the right solution if you have so many visitors.
Alternatively, you may use services like Bugsnag to get what's going on in your app.
Replied to Passing Multiple Parameters In Route To Controller
@shamsul_huda Not sure why it doesn't work but you can try this one as well instead of using name routing.
<a href="'/book/category/' . {{ $category->id }} . '/' . {{ $category->slug }}" class="row author-content px-0">View</a>
Replied to Defining Relationships Within Factories
@newbie360 Actually,
This is the definition where you define from where you get video_id
by default.
public function definition()
{
return [
'video_id' => Video::factory(), // why we need this line ?
];
}
You mentioned that, if this class will be called, then
video_id
by newly created video factory id.The following is doing the same thing, but multiple times with some extra facilities.
public function run()
{
Video::factory()->count(10) // create 10 videos
->hasVideoKeywords(2) // each video add 2 keywords
->create();
}
Replied to Multiple Approval Process In Laravel
@prasadchinwal5 A general rule of thumb:
If you CC / mention someone in your thread, other contributors may ignore your question. :)
Awarded Best Reply on Search In Table Related To Eloquent
@datanorte You can use whereHas()
in that case. I assume that brand
table has name
field and category
has title
filed those you want to search.
public function render()
{
$data_products = Product::with('brand', 'category')->orderBy('id', 'desc')
->where('name', 'like', '%' . $this->search . '%')
->orWhereHas('brand', function($query) use($search = $this->search){
$query->where('name', '%' . $search . '%')
})->orWhereHas('category', function($query) use($search = $this->search){
$query->where('title', '%' . $search . '%')
})->paginate($this->perPage);
return view('livewire.products', compact('data_products'));
}
Note: You need to adjust the query based on your requirements.
Ref: https://laravel.com/docs/8.x/eloquent-relationships#querying-relationship-existence
Awarded Best Reply on IsoFormat Error In Laravel
@amit028 Is that somehow a composer installation issue?
Can you try this?
composer clearcache
composer install
Replied to Composer Error When I Try To Use Composer Commands
@deekshith It's a php / laravel package.
Allow you to display update/upgrade instructions to your library users.
Replied to Composer Error When I Try To Use Composer Commands
@deekshith This means, your php version is 7.1.33 but for some reasons (probably some of the packages need a higher version of php) composer required 7.2.5 version or above.
So, if possible, I strongly suggest you to upgrade php version at least. It's recommeneded also to upgradate Laravel version (The current version is 8 and you are using 5.5)
Replied to Composer Error When I Try To Use Composer Commands
@deekshith Try-
I have had to delete the directory
kylekatarnls
located inside myvendor
directory then runcomposer update --prefer-source
and after thatcomposer dump-autoload
.
Replied to Take Specific Column From Multi-dimensional Arra
@tapas Doesn't it simpler approach?
Model::get('company_name', 'position');
Replied to Connection With Multiple Database In Lumen
Replied to Display Products Of Each Category In Laravel
@mehrdad70 Try this-
public function showCourses()
{
$courses = Course::with('categories')->get()
retuern view('front.courses.all-courses', compact('courses'));
}
@foreach($courses as $course)
// To print anything from category table
{{ $course->categories->fieldName }}
@endforeeach
Here you need to adjust the fieldName
based on your table column.
SideNote: I highly recommend you to check this doc and watch some basic laravel series that will boost up your skills.
Replied to How To Save Two Different Data In One Column.
@emfinanga It's because of you are assigning slave_id
into unit_id
. Look at your following code that is wrong-
$data = New Mystock;
$data->unit_id = $value->unit_issue_id;
$data->unit_id = $value->slave_id;
It should be like this-
$data = New Mystock;
$data->unit_id = $value->unit_issue_id;
$data->slave_id = $value->slave_id;
...
You just adjust your $data->slave_id
if the table column is wrong.
Replied to Develop RSS News Feed With Laravel And RSS Tracker In Localhost?.
@munazzil It's a big old tho, but you can follow that.
https://www.itsolutionstuff.com/post/task-scheduling-with-cron-job-in-laravel-58example.html
Replied to Best🪡Way
@konstruktionsplan First of all, your query has an issue mentioned by @prasadchinwal5 . Check it out.
Secondly, if you are looking for the best way, then I would recommend you to use eloquent for that. Since you are able to join tables via the foreign key, you can easily build a relationship between them. Then you can create a dedicated method to grab the point.
Replied to File Upload Refactoring
@uniqueginun The approach suggested by @tray2 looks clean enough already.
Why not you just create separate methods and handle all the logic insider them.
BTW, you can use a loop if you want, but since you can solve any issue without the loop, then what is the purpose of using it? Looping will make iteration, which may affect your performance (depends on how many times it iterate). Therefore I believe looping is unnecessary use here.
Replied to Develop RSS News Feed With Laravel And RSS Tracker In Localhost?.
@munazzil If I understand you correctly, you want to fetch real-time.
In that situation, you need to use any JS library / Cron Job for pulling data at certain intervals. Or you need to use any third-party library to solve the issue.
Replied to File Upload Refactoring
@uniqueginun First of all, if your current code works fine, I would say just follow the simple step, that currently has.
Secondly, if you submit multiple form on same action and not sure whether in future it will submit more form or not, on that situation, you can follow a separate class for each form submittion based on a contract (Interface), that will be following Open Closed Principle (Some may be refer it over engineering of it here).
That's what I can think of now.
Awarded Best Reply on Accessing Parent Method From Subclass Instantiation
@zaimazhar You just add return $this;
in your awarded()
method. That should work.
public function awarded($user) {
$this->user = $user;
return $this;
}
Replied to Accessing Parent Method From Subclass Instantiation
@zaimazhar You just add return $this;
in your awarded()
method. That should work.
public function awarded($user) {
$this->user = $user;
return $this;
}
Replied to File Upload Refactoring
@uniqueginun Why do you need refactoring here? I cannot see any complexity here.
Earned once your experience points ranks in the top 10 of all Laracasts users.