MarianoMoreyra

MarianoMoreyra

Member Since 2 Months Ago

Buenos Aires

Experience Points
36,380
Total
Experience

3,620 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
108
Lessons
Completed
Best Reply Awards
42
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    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.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 8
36,380 XP
Sep
19
22 hours ago
Activity icon

Replied to Trying To Perform Migration "Illuminate\Database\QueryException"

Hi @monstajamss

Seems like you don't have a table defined at the config file where you are trying to get it, so this line it must be returning an empty string:

config('eloquent-viewable.models.view.table_name')

Take a look at that config file and see if you've misspelled the name of a folder of the variable itself

Activity icon

Replied to Help Building A Query Or Using Eloquent

Hi @schwartzmj

You are Eager Loading the relationship there, so you shouldn't need to go to database again.

Maybe it's not the nicest way, but if you can only get 1 application per year, then you can just take the first() element from the collection:

<td>
    @if ($family->applications->isNotEmpty())
            {{ $family->applications->first()->status }}
    @else
        Not Created
    @endif
</td>

or maybe you can make it shorter like this:

<td>
        {{ $family->applications->first()->status ?? "Not Created" }}
</td>
Sep
18
1 day ago
Activity icon

Replied to Relationships With A "type" Of Relationship

Hi @lmangold@outlook.com

I’m not sure if I understand your need, although it really seems to me that what you are needing is a Polymorphic Relationship: https://laravel.com/docs/master/eloquent-relationships#one-to-one-polymorphic-relations

Hope that’s it!

Activity icon

Replied to Get Model Items Included In Relationship (categories That Have Products)

@msslgomez actually, reading again, you should use whereHas instead so you can filter the Products using a whereIn and passing your $products list.

Sorry I can’t write an example for you, as I’m at my phone and it gets hard to write that code hehe

Activity icon

Replied to Jeffrey's Test Setup

Hi @justageek

If I’m not wrong, Jeffry uses Valet (only available for Mac users) which allows to create new virtual hosts easily for each new project.

If you are a Windows user, you can use Homestead, or Laragon, similar to Valet.

I'd recommend Laragon if you want to have your projects quickly up and running and with less resources using than Homestead.

Sep
17
2 days ago
Activity icon

Replied to X-component : Cannot Pass Variable In <>

That’s great @jntng

Glad I was able to help!!

Activity icon

Awarded Best Reply on X-component : Cannot Pass Variable In <>

Hi @jntng

Your code should work as is, unless it's not an anonymous component, in which case you have to declare the $title as a public attribute at your Layout class and pass it to the constructor.

If it's indeed an anonymous component, the title should be there. Have you trying inspecting the source code of the resulting page to see if it's there but hidden for some reason?

Sep
16
3 days ago
Activity icon

Replied to X-component : Cannot Pass Variable In <>

Hi @jntng

Your code should work as is, unless it's not an anonymous component, in which case you have to declare the $title as a public attribute at your Layout class and pass it to the constructor.

If it's indeed an anonymous component, the title should be there. Have you trying inspecting the source code of the resulting page to see if it's there but hidden for some reason?

Activity icon

Awarded Best Reply on How To Make Query For Fetching Specific Id In Eloquent Many To Many?

Hi @mimiloca

You are not specifying any club id in your Eloquent query.

If you want to get the club with id 2 you should do:

$clubs = Club::with('members')->where('id', 2)->get();

Although, you should pass the id to your show method:

public function show($id)
{
    $clubs = Club::with('members')->where('id', $id)->get();

    return view('club.member')->with('club', $clubs); 
}

and update your route to pass that variable

Activity icon

Replied to How To Make Query For Fetching Specific Id In Eloquent Many To Many?

Hi @mimiloca

You are not specifying any club id in your Eloquent query.

If you want to get the club with id 2 you should do:

$clubs = Club::with('members')->where('id', 2)->get();

Although, you should pass the id to your show method:

public function show($id)
{
    $clubs = Club::with('members')->where('id', $id)->get();

    return view('club.member')->with('club', $clubs); 
}

and update your route to pass that variable

Activity icon

Replied to When I Required Selectize Js In Laravel Mix It Get Me Error Is Not A Function

Hi @hasanhatem

You have a typo. It's not required, it's require:

require('selectize');
Sep
15
4 days ago
Activity icon

Replied to Accessing Model Properties In Scope

Hi @expdev07

If I understand correctly what you need, maybe you could try comparing directly to the post user_id field, like this:

    public function scopeNotBlocked($query, User $user): Builder
    {
        // Query for posts where creator has not blocked the provided user or the user has blocked the creator.
        return $query->whereDoesntHave('user.blocks', function (Builder $query) use ($user) {
            $query
                ->where('user_id', 'posts.user_id')
                ->orWhere('blocked_id', $user->id);
        });
    }

As you can see, I'm assuming that your Posts table is named posts and that the creator foreign key is user_id

Hope this helps!

Activity icon

Replied to How To Use OrgChart JS In Vue

Hi @tarang19

Have you try following the steps recommended at their documentation?

docs: https://balkangraph.com/OrgChartJS/Docs/Vuejs

Hope this helps!

Sep
14
5 days ago
Activity icon

Replied to Help With Filter Using Pipelines. Laravel 7

Hi @ajsmith_codes

Just to be sure, your requested_ship_date field is a Date, DateTime or Timestamp field right?

Also, you are not copying your entire Filter base class...just the handle method...so I guess you just left that second return statement by mistake?

Finally, could you please copy the url you are using? Are just using the same as the example like this?

http://127.0.0.1:8000/post?active=1&sort=desc&max_count=1

Activity icon

Replied to Return View Dost'nt Work

You're welcome @hendrasaputra2323 !!

Glad I was able to help!

Activity icon

Replied to Return View Dost'nt Work

@hendrasaputra2323 I just saw this:

This my href to acces link

href="{{ route('tag.update', $hasil->id ) }}">

So you should change that to

href="{{ route('tag.edit', $hasil->id ) }}">

as I said before, as that route is the one that you should hit from your edit form to actually save the changes

Activity icon

Awarded Best Reply on Return View Dost'nt Work

Well @hendrasaputra2323, because a translation problem, I'm not sure which one is your Edit button in that code, but if it's this:

<a class="flex items-center mr-3" href="{{ route('tag.update', $hasil->id ) }}"> <i data-feather="check-square" class="w-4 h-4 mr-1"></i> Ubah </a>

Maybe you should change the route to the update one, like this:

<a class="flex items-center mr-3" href="{{ route('tag.edit', $hasil->id ) }}"> <i data-feather="check-square" class="w-4 h-4 mr-1"></i> Ubah </a>

Although I could be missing something else out

Activity icon

Replied to Return View Dost'nt Work

Well @hendrasaputra2323, because a translation problem, I'm not sure which one is your Edit button in that code, but if it's this:

<a class="flex items-center mr-3" href="{{ route('tag.update', $hasil->id ) }}"> <i data-feather="check-square" class="w-4 h-4 mr-1"></i> Ubah </a>

Maybe you should change the route to the update one, like this:

<a class="flex items-center mr-3" href="{{ route('tag.edit', $hasil->id ) }}"> <i data-feather="check-square" class="w-4 h-4 mr-1"></i> Ubah </a>

Although I could be missing something else out

Activity icon

Replied to Return View Dost'nt Work

@hendrasaputra2323 if you say you are trying to access the EDIT view, then the route should be localhost:8000/tag/1/edit instead of localhost:8000/tag/1

Activity icon

Replied to Return View Dost'nt Work

@hendrasaputra2323 you should have

@section('judul', 'Edit - Tag Berita')
@endsection

@section('content')

If I’m not wrong

Activity icon

Replied to Return View Dost'nt Work

Hi @hendrasaputra2323

Check that you are not closing/ending the judul section before opening the content one.

Try closing it and see if that’s it

Activity icon

Replied to Open Source Laravel Projects For Learning?

Hi @martinzeltin

I believe any package from Spatie could be a great source to start as they have a great coding quality!

Also, you can take a look at these projects as you may find one that you can analyze:

I believe that’s a starting point!

Sep
13
6 days ago
Activity icon

Awarded Best Reply on Models Is Not Working In Laravel 8

Hi @araw

At your controller you are importing the Model with a wrong namespace:

use App\Product;

while your Product it's declared at this other namespace:

namespace App\Models;

So, try changing to this at Controller:

use App\Models\Product;

Hopefully, that's it!

Sep
12
1 week ago
Activity icon

Replied to Models Is Not Working In Laravel 8

Hi @araw

At your controller you are importing the Model with a wrong namespace:

use App\Product;

while your Product it's declared at this other namespace:

namespace App\Models;

So, try changing to this at Controller:

use App\Models\Product;

Hopefully, that's it!

Sep
11
1 week ago
Activity icon

Replied to Validate Existing File

Hi @rsarvarov

Maybe you could create an instance of Illuminate\Http\UploadedFile passing the corresponding parameters for your file:

$file = new UploadedFile(storage_path('your_file.png'),
    'your_file.png',
    'image/png',
    null,
    true);

Then you can use a custom validator and call it passing the loaded file inside an array. Maybe something like:

   $validator = Validator::make($file, [
        'file' => 'image|mimes:png|size:2048',
   ]);

Hope this works, as I haven't had the opportunity to test this solution!

Activity icon

Replied to ErrorException Unresolvable Dependency Resolving [Parameter #0 [ <required> $auth_profile ]] In Class App\View\Components\userprofile\profileInfo (View: C:\laragon\www\acl\resources\views\userprofile\profile-page.blade.php) Http://acl.test/auth_profile/1/

Hi @neeraj1005

I believe Laravel doesn't like your variable notation when it comes to variable binding.

Try changing your component usage at your blade file to:

            <x-userprofile.profile-info :auth-profile="$auth_profile" />

(note that I'm changing the :auth_profile to :auth-profile)

and then at your component class change your constructor to:

    public function __construct($authProfile)
    {
        $this->auth_profile = $authProfile;
    }

Check the Casing sub-section at the Passing Data To Components section of docs. ref: https://laravel.com/docs/7.x/blade#passing-data-to-components

Hope this works!

Sep
10
1 week ago
Activity icon

Replied to Target Class [Admin\LoginController] Does Not Exist

Hi @artisticre

Just in case...you haven't changed the namespace at your RouteServiceProvider right?

Do you still have?:

protected $namespace = 'App\Http\Controllers';
Sep
02
2 weeks ago
Activity icon

Replied to I Am Trying To Get Total Amount Conditional And Per Month

Hi @ehabafia

Try with something like this (not sure if it should go at your relationship definition tho):

    public function monthly_totals()
    {
        return $this->hasMany(Transaction::class)
            ->select(DB::raw('YEAR(created_at) year, MONTH(created_at) month, SUM(IF(type="credit", amount, amount * (-1))) total'))
            ->groupBy('year, month')
            ->get();
    }

Hope this works for you!

Activity icon

Replied to HasManyThrough Relationship With Data From Intermediate Table

That's great @cisaia !!

Glad I was able to help you!

Activity icon

Awarded Best Reply on HasManyThrough Relationship With Data From Intermediate Table

Hi @cisaia

Actually, what you have there it's a Many to Many relationship (unless I'm missing something), so maybe it should be easy to define it as that:

ref: https://laravel.com/docs/7.x/eloquent-relationships#many-to-many

Then, you can access any additional columns in your pivot (or intermediate) table by using the following at your relationship definition:

return $this->belongsToMany('App\Role')->withPivot('column1', 'column2');

in your example would be something similar to:

return $this->belongsToMany('App\Models\ProductItemModels\product_items')->withPivot('order');

Hope this helps! (and that I'm not missing something here)

Activity icon

Replied to HasManyThrough Relationship With Data From Intermediate Table

Hi @cisaia

Actually, what you have there it's a Many to Many relationship (unless I'm missing something), so maybe it should be easy to define it as that:

ref: https://laravel.com/docs/7.x/eloquent-relationships#many-to-many

Then, you can access any additional columns in your pivot (or intermediate) table by using the following at your relationship definition:

return $this->belongsToMany('App\Role')->withPivot('column1', 'column2');

in your example would be something similar to:

return $this->belongsToMany('App\Models\ProductItemModels\product_items')->withPivot('order');

Hope this helps! (and that I'm not missing something here)

Activity icon

Replied to HTML Input Array Not Working

Hi @computermaverick

Have you checked your request to see if the array gets submitted?

Also, could you post the Controller method corresponding to your courses.store route to see how it's handling the array (in case it's receiving an array of course)?

Aug
31
2 weeks ago
Activity icon

Replied to Laravel + Vuetify Vs Livewire + Tailwind

Hi @mtdalpizzol

Have you considered Inertia.js? It seems to tackle some of the downsides mentioned without having to change entirely to a new stack. (I must warn you that I haven't had the opportunity to fully try it myself)

From it's documentation:

1.Duplicated validations: validations which are ready out of the box on Laravel needed to be duplicated with vee-validate on the client side.

You can keep your server side validations without duplicating at client side: https://inertiajs.com/forms#server-side-validation

2.Another problem is related with URLs. I love Laravel’s named routes and these are the only way I reference and generate URLs on my app. Not having access to these functionality on the client side sucks and I don’t like using something like ziggy, which adds code to be delivered to the user for something that is ready on the server.

Here you'll still miss having named routes at client side, although they offer some alternatives (including ziggy which you already said you don't like it): https://inertiajs.com/routing

3.Handling permissions on the client side sucks. I love Laravel’s policies approach and I think it’s a real loss having to map permissions to a JavaScript object so Vue.js can decide what to and what no to render, for example

I don't know if it's the best way it's handled. I guess it's almost the same as mapping permissions to a Javascript object as you said, although they make it seem clean at least: https://inertiajs.com/security

Also, you can check this post from Freek Van der Herten (from Spatie) showing how they've implemented front-end authorization using Inertia: https://freek.dev/1391-how-to-handle-front-end-authorization-using-laravel-inertia-and-typescript

Anyway...maybe it still haves some of the downsides, although once again...it offers some interesting solutions while you can keep using Vue and Vuetify just like you've been doing.

For more info, you can check this blog that makes a comparison between Inertia and Livewire: https://sebastiandedeyne.com/inertia-js-and-livewire-a-high-level-comparison/

Hope all this helps!

Aug
30
2 weeks ago
Activity icon

Awarded Best Reply on Where In SubQuery

Hi @ehabafia

If I correctly understand your need, I think this is what you need:

    public function scopeNewBorrowers($query)
    {
        return $query->doesntHave('finances');
    }

ref: https://laravel.com/docs/7.x/eloquent-relationships#querying-relationship-absence

Hope this helps!

Activity icon

Replied to Where In SubQuery

Hi @ehabafia

If I correctly understand your need, I think this is what you need:

    public function scopeNewBorrowers($query)
    {
        return $query->doesntHave('finances');
    }

ref: https://laravel.com/docs/7.x/eloquent-relationships#querying-relationship-absence

Hope this helps!

Aug
28
3 weeks ago
Activity icon

Replied to CSRF Token Mismatch On Laravel-sites On Example.org And Staging.example.org

Have you tried restarting the service and clearing caches?

Activity icon

Replied to CSRF Token Mismatch On Laravel-sites On Example.org And Staging.example.org

Hi @ahoi

At your main domain you have this config:

SESSION_DOMAIN=.example.org

which includes every subdomain because of that leading dot. I guess that could be in conflict with your staging subdomain session management.

Try changing your main config to

SESSION_DOMAIN=example.org

and see if that works

Aug
27
3 weeks ago
Activity icon

Replied to Filter A Query By Range Of Hours

Hi @gbeltran

You could try something like:

DB::table('paperchecks') 
    ->whereBetween('timeOfArrival', array($from_date_utc, $to_date_utc))
    ->whereRaw('TIME(timeOfArrival) >= ? AND TIME(timeOfArrival) <= ?', ["16:00:00", "18:00:00"])
    ->get();

Hope this helps!

Activity icon

Replied to Print Eloquent Result In Blade

Hi @ethar

The thing is that you "student_course" seems to be a Collection, so you can't ask for it's course attribute just like that.

So you should iterate on student_course too, although, as you seem to have only one element inside, you could just to something like:

@foreach($studentCourse as $courses)
       <h6>{{ $courses->student_course->first()->course->title_ar }}</h6>
@endforeach

or in case it's an array you could simply try with:

@foreach($studentCourse as $courses)
       <h6>{{ $courses->student_course[0]->course->title_ar }}</h6>
@endforeach
Aug
26
3 weeks ago
Activity icon

Awarded Best Reply on Js File Get Complie But No Working

@sohail49 try changing this:

window.Vue = require = ('vue');

To this:

window.Vue = require('vue');
Activity icon

Replied to Js File Get Complie But No Working

@sohail49 try changing this:

window.Vue = require = ('vue');

To this:

window.Vue = require('vue');
Aug
25
3 weeks ago
Activity icon

Replied to Laravel - 7 Excel File Import With Column Key Exist Or Not Validation

Hi @kp_sahani

Instead of returning a json and exiting, try throwing a custom ValidationException. Something like:

        if( $key == 0 ){
            if($row[0] != 'name' || $row[1] != 'product_code' || $row[2] != 'item_number' || $row[3] != 'description' || $row[4] != 'unit_cost' || $row[5] != 'extended_cost' || $row[6] != 'status'){
		
		throw ValidationException::withMessages('Invalid headers or missing column');

            }
        } 

Remember to add the:

use Illuminate\Validation\ValidationException;

at the top of your Import class.

In my case, as I have several imports at one project, I made a helper function that receives an array with valid headers and the imported keys to compare them using diffAssoc and informing which header is missing.

public function headersValidation($valid, $imported)
{
    if($imported->diffAssoc($valid)->count() > 0) 
    {
        foreach($imported->diffAssoc($valid) as $field) {
            $errors[$field] = "Missing or wrong header: ".$field. " (valid: " . implode(", ", $valid) .")";
        }
        throw ValidationException::withMessages($errors);
    }

    return true;
}

Hope this helps!

Activity icon

Awarded Best Reply on Get Unique Values Of Eloquent Relationship

Hi @stefan7

I don't know if it's a 'good way' but, it's one way :)

You could try something like this:

// change 'branch_name' to whatever is your branch description field
$branches = $products->pluck('branches')->collapse()->pluck('branch_name', 'id');

Believe it or not...it should work, and the last 'keyed' pluck should give you the unique branches, well...just because you are using the table id as the key of the resulting collection.

Hope this works for you!

Aug
24
3 weeks ago
Activity icon

Replied to Get Unique Values Of Eloquent Relationship

Hi @stefan7

I don't know if it's a 'good way' but, it's one way :)

You could try something like this:

// change 'branch_name' to whatever is your branch description field
$branches = $products->pluck('branches')->collapse()->pluck('branch_name', 'id');

Believe it or not...it should work, and the last 'keyed' pluck should give you the unique branches, well...just because you are using the table id as the key of the resulting collection.

Hope this works for you!

Activity icon

Awarded Best Reply on 404 Not Found, Route Exists Laravel 7

@ryahn have you checked if the received id exists at your Users table, and that it has not been previously 'soft deleted'?

Activity icon

Replied to 404 Not Found, Route Exists Laravel 7

@ryahn have you checked if the received id exists at your Users table, and that it has not been previously 'soft deleted'?

Activity icon

Replied to 404 Not Found, Route Exists Laravel 7

@ryahn that's another example of a route where you are injecting a model, so if the id that you are passing to that route doesn't exists, you'll get a 404 too, despite the route does indeed exists.

Activity icon

Replied to 404 Not Found, Route Exists Laravel 7

Hi @ryahn

Have into consideration that 404 it's not only returned when the route doesn't exists, but also when you pass an id as a parameter to a Model injected to your Controller's method, just like you have at line 199:

public function destroy(User $id)

and also when you do a findOrFail passing an id that doesn't exists either for that model, like you do at line 72:

$user = User::findOrFail($id);

Just to be sure, check if any of those might be returning a 404 instead of the route itself.