560 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 Auth Guard Sanctum Not Defined
@krie9er are you sure you published the Sanctum configuration files?
Replied to Trigger Onchange Vue
@chron @change
is only triggered when there is a change from the input element.
I would suggest that you check the watchers
instead https://vuejs.org/v2/guide/computed.html#Watchers
Awarded Best Reply on How To Add A Prefix To A Custom Blade Component.
@embee have you tried:
$this->callAfterResolving(BladeCompiler::class, function () {
Blade::component('base-input-container', BaseInputContainer::class);
Blade::component('sunfire-base-input-container', BaseInputContainer::class);
});
Replied to What Are The Options For Themes/skins For Laravel Spark?
@chrisjcraft have you check https://themeforest.net/search/laravel%20spark ?
Replied to Eloquent - Insert If Not Exists
@andyandy you can use firstOrCreate
foreach ($XML as $item) {
PossibleCombinationsOfProductAndVariant::firstOrCreate([
'product' => $item->product_name,
'variant' => $item->variant_name
]);
}
Awarded Best Reply on How To Print Foreign Data Values?
@warpig I think you have to call the tags inside the post? like this:
@foreach ($post->tags as $tag)
<span><p class="date"> {{ $tag->name }} </p></span>
@endforeach
In your Post Model:
public function tags() {
return $this->belongsToMany(Tag::class);
}
In your Tag Model:
public function posts() {
return $this->belongsToMany(Post::class);
}
Replied to How To Add A Prefix To A Custom Blade Component.
@embee I'm not sure if I can answer this correctly as I'm not familiar yet with Jetstream but if you look closely, the second parameter of Blade::component
in your code is a class, but in Jetstream, it looks like it's another component that seems "aliasing" another component (as I said, I might be wrong). But to test this out you could try:
$this->callAfterResolving(BladeCompiler::class, function () {
Blade::component('base-input-container', BaseInputContainer::class);
Blade::component('sunfire-base-input-container', 'base-input-container'); // here
});
Because 'jet-'.$component
seems already configure by Jetstream itself, so if you want to change it to sunfire
you might need to do it like this:
Blade::component('jetstream::components.'.$component, 'jet-'.$component); // leave it here
Blade::component('sunfire::components.'.$component, 'jet-'.$component);
Blade::component('sunfire-'.$component, 'jet-'.$component);
Again, I might be wrong, I haven't tried this.
Also, please mark the answer "Best Answer" if you find it helpful so others can benefit from it to ;)
Replied to How To Add A Prefix To A Custom Blade Component.
@embee have you tried:
$this->callAfterResolving(BladeCompiler::class, function () {
Blade::component('base-input-container', BaseInputContainer::class);
Blade::component('sunfire-base-input-container', BaseInputContainer::class);
});
Replied to Filter Product's Price By Regular Price If Sale Price Is Empty?
DB::table('products')->selectRaw('COALESCE(sale_price, regular_price) as price')->get();
Replied to Fail To Pass User Selected Data To PDF View Laravel DOMPDF
well looks like you are submitting in the correct path? but your controller might be the problem?
Replied to Email Is Getting Sent Multiple Times In Laravel
@shiva how about instead, get the outstanding post on the User model instead of Post? So you can create a relationship on the User model like:
User Model:
public function outstandingPosts()
{
return $this->hasMany(Post::class)
->where('status', 'Waiting on Moderator')
->orWhere('status', 'Waiting on User')
->orWhere('status', 'Moderator Rejected');
}
Then
$outstandingPosts = User::has('outstandingPosts')->get();
foreach($outstandingPosts as $user)
{
// Get all the posts that is attached to either a moderator or a poster
$op = Post::where('moderator_id', $user->id)
->orWhere('poster_id', $user->id)
->get();
// Send email to that user with their outstanding posts
Mail::to($user->email)->queue(new OutstandingPosts($op));
}
Replied to Fail To Pass User Selected Data To PDF View Laravel DOMPDF
@mariaaa can you post here the error? and what URL you landed on? check where you got redirected.
Replied to How To Print Foreign Data Values?
@warpig I think you have to call the tags inside the post? like this:
@foreach ($post->tags as $tag)
<span><p class="date"> {{ $tag->name }} </p></span>
@endforeach
In your Post Model:
public function tags() {
return $this->belongsToMany(Tag::class);
}
In your Tag Model:
public function posts() {
return $this->belongsToMany(Post::class);
}
Replied to HTML/CSS To PDF Library
@anandi what seems to be the problem with the packages you mentioned?
Replied to Email Is Getting Sent Multiple Times In Laravel
Have you tried adding groupBy
?
$outstandingPosts = Post::where('status', 'Waiting on Moderator')
->orWhere('status', 'Waiting on User')
->orWhere('status', 'Moderator Rejected')
->groupBy('moderator_id', 'poster_id')
->get();
Awarded Best Reply on Unable To Locate Publishable Resources.
Replied to Email Is Getting Sent Multiple Times In Laravel
@shiva looks like your $outstandingPosts
contains duplicate $user
.
Can you share your Post Model?
Replied to Unable To Locate Publishable Resources.
Try clearing your config as well:
php artisan config:clear
Replied to Fail To Pass User Selected Data To PDF View Laravel DOMPDF
@mariaaa the onclick="location.href = '/home/billing/pdf';"
seems to be the problem, it's redirecting to that url before the ajax request happens.
What you can do is to add the location.href
to the success method of your ajax request.
success:function(data){
location.href = '/home/billing/pdf';
// or window.location
},
Replied to Unable To Locate Publishable Resources.
Awarded Best Reply on QR Code
@rabeedmenam you can use this package to create the QR code https://github.com/SimpleSoftwareIO/simple-qrcode. You can't change the text that is generated from the QR code though.
But if what you meant is the content of the URL you are generating then it's possible on the server-side. An example is when you hit domain.com/content/1
, then just change its content on the DB.
Replied to Relation Conditions
@kshitizmittal if your goal is to just dynamically change those static values then you could do:
$band = 1;
$level = 1;
$appraisalForm = AppraisalTemplate::where(['id' => $id])->with(['goals', 'questions', 'competencies.parameterDetails.categoryDetails','departmentDetails','designationDetails.positionDetails','competencies.parameterDetails.questions'=>function($query) use ($band, $level){
$query->where(['band'=>$band,'level'=>$level]);
}])->first();
Just pass the variables in the use()
section.
Replied to User Authentication From Other Domain
@kubitomakita looks like you haven't configured your CORS, check here: https://laravel.com/docs/8.x/sanctum#cors-and-cookies
Replied to Php Artisan Error(failed To Open Stream: No Such File Or Directory)
@mastertech01 you might think that your composer install was a success but wasn't mainly because your PHP version is not compatible?
On this package, it requires PHP 7.2.5.
Check your PHP version first.
Replied to Php Artisan Error(failed To Open Stream: No Such File Or Directory)
@mastertech01 looks like your composer install
wasn't successful at all.
require(C:_project\web\prediction/vendor/autoload.php): failed to open stream: No such file or directory in C:_project\web\prediction\artisan on line 18
this error means you don't have the vendor/autoload.php
which can be only generated via composer.
Are you sure you are in the correct directory?
Replied to Url Methods In Laravel
@erfanwd Don't forget to mark an answer as the best answer if it answers your question ;) Thanks!
Replied to Url Methods In Laravel
Well, it looks different from what you just said earlier. Looks like what you need is to create each Model on each category like Poster and T-shirts because each contains different attributes as well.
Or create a Products table that contains all the categories, so product table will have a category column which contains poster, tshirt and maybe linked to a meta table (like Wordpress) that contains the custom attribute.
products table
id | name | category
1 | test 1 | tshirt
2 | test 2 | poster
etc...
meta table
id | product_id | key | value
1 | 1 | size | medium
2 | 1 | price | 50
3 | 2 | color | blue
etc...
Replied to Url Methods In Laravel
Are the products will come in a single model (in other words, products
table?) or different Models like Poster
, TShirt
, etc?
Replied to Laravel Nova Updated Courses
@boubou I suggest not touch the base code but implement your own. For example, if you want to update the login logic, you can add the same routes in your web.php and those will be overwritten.
You can check the list of nova routes using php artisan route:list
and add it to your web.php with your custom controller.
Replied to Url Methods In Laravel
@erfanwd if I understand correctly, you want to get the my-fine-art-name
depending on the model which is the product-type
that can be poster, t-shirt etc...
web.php
Route::get('/product/{$product}', function($product){
if (request('product-type') == 'poster') {
return Poster::where('product_name', $product)->first();
}
// other if condition here for t-shrit, etc...
});
Replied to QR Code
@rabeedmenam you can use this package to create the QR code https://github.com/SimpleSoftwareIO/simple-qrcode. You can't change the text that is generated from the QR code though.
But if what you meant is the content of the URL you are generating then it's possible on the server-side. An example is when you hit domain.com/content/1
, then just change its content on the DB.
Replied to Spatie Permission Sync Error
@aavinseth I think you need to add protected $guard_name = 'web,auth'
in your Model.
Replied to Openssl_pkcs7_sign(): Error Getting Private Key
@ado666 can you add the following:
$certificate = 'file://' . realpath('/var/www/xx/xx/cert/3ecs_sign.crt');
or if not, try this:
$certificate = __DIR__ . realpath('/var/www/xx/xx/cert/3ecs_sign.crt');
Replied to Looking To Design The Best Eloquent Relationship Between A User, A Service And Service Options.
@cosminc looks like those models are chain with one another, you can do this:
User.php
public function services()
{
return $this->hasMany('App\Service')->with('options');
}
Service.php
public function options()
{
return $this->hasMany('App\Option');
}
Option.php
public function service()
{
return $this->belongsTo('App\Service');
}
so you can loop on $users->services
and loop the options inside the services.
Replied to Get Root URL From UrlGenerator
@rushita not sure what you meant by root but url()->full()
is what you are looking for?
Replied to How Can I Clone Row And Relationship Into Another Table?
@crazylife I think you have to loop all the relationship like this:
$old = $order->replicate();
$old->save();
foreach($order->items as $item)
{
$old->items()->attach($item);
}
foreach($order->history as $history)
{
$old->history()->attach($history);
}
$old->push();
Replied to Laravle Where() And OrWhere() Not Working Properly.
@alexgodbehere79 try:
return LinkRelation::where(function ($query) {
$query->where([
'source_key' => 2,
'target_key' => 4
])->orWhere([
'source_key' => 4,
'target_key' => 2,
]);
})->first();
Replied to How Can I Get Only Last Product Meta Of These Dates?
@kfazil have you tried:
$data = Product::with([ 'productMeta' => function ($query) use ($date_1, $date_2) {
$query->whereDate('date_column', $date_1)
->orWhereDate('date_column', $date_2)
->latest()
->first();
}])->orderBy('created_at', 'desc')->get();
Awarded Best Reply on Laravel Version Upgrade
@deepak475121 depends on your project, does it need an update? Why?
In my case, we are running Laravel 4.2 projects without a problem but decided to upgrade some to 8.0 because we need to use a package that requires a higher Laravel version.
And if you decide to upgrade, I would suggest you install a fresh Laravel and manually copy your files instead of upgrading your version inside your project. It will also help if you have PHPUnit test in place so you check if your project works as expected.
Alternatively, you can use Laravel Shift https://laravelshift.com/
Replied to Laravel Version Upgrade
@deepak475121 depends on your project, does it need an update? Why?
In my case, we are running Laravel 4.2 projects without a problem but decided to upgrade some to 8.0 because we need to use a package that requires a higher Laravel version.
And if you decide to upgrade, I would suggest you install a fresh Laravel and manually copy your files instead of upgrading your version inside your project. It will also help if you have PHPUnit test in place so you check if your project works as expected.
Alternatively, you can use Laravel Shift https://laravelshift.com/
Replied to Php Artisan Serve
@mupenzi make sure you add those classes in your config/app.php
Add this in your providers
array
Mpociot\BotMan\BotManServiceProvider::class,
And in the aliases
array
'BotMan' => Mpociot\BotMan\Facades\BotMan::class
Try it and if it still doesn't work composer dump-autoload
might help as well.
Replied to Laravel Variable From Edit Become Blank
@obink instead of doing the findOrFail manually, try to check your route by running php artisan route:list
. Find the route for your Homeworks
and you will see the parameter that I'm talking about. Then you can pass it to the edit function like:
public function edit(Homeworks $homework)
where $homework
is the name of the parameter in the route list.
But glad it works with your solution.
Replied to Livewire Many Input Fields
@amitshrestha221 what I do instead is create an array property like this:
public $myform = [];
And in my form:
<input type="text" wire:model="myform.title">
<input type="text" wire:model="myform.body">
<input type="text" wire:model="myform.etc">
Replied to Issue W/ Converting PDF's W/ Spatie MediaLibrary
@whoisthisstud @mduzair must be Ghostscript version?
Replied to Laravel Variable From Edit Become Blank
@obink you have a route model binding situation right here.
I think it's working as expected although you need to make sure that the id
you pass in your route is correct and also named properly.
Can you check your route for admin.homeworks.edit
? The parameter there should be the same as your public function edit(Homeworks $homeworks)
in other words, it should be named homeworks
like this:
Route::get('homeworks/edit/{homeworks}', [HomeworkController::class, 'edit']);
Replied to Nginx Point To Public
@jlrdw if you want to point your server to the public directory of your laravel project, you can just set the root directory like this inside the server
server {
root /var/www/your-laravel-project/public;
// your other configurations...
}