squiaios

squiaios

Member Since 9 Months Ago

Experience Points
4,510
Total
Experience

490 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
0
Lessons
Completed
Best Reply Awards
7
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 1
4,510 XP
Oct
26
1 month ago
Activity icon

Replied to I Want To Create One To Many Relationship | With If Condition | (Category Has Many Subcategories)

For me, Subcategory is useless in your case.

In Category, add parent_id which is nullable by default

and you can have access using this:

class Category extends Model
{
	/** @var string[] $fillable */
	protected $fillable = [
		'name',
		'parent_id',
		// ...
	];

	/**
	 * @return \Illuminate\Database\Eloquent\Relations\HasMany
	 */
	public function subcategories()
	{
		return $this->hasMany(self::class, 'parent_id');
	}

	/**
	 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
	 */
	public function parent()
	{
		return $this->belongsTo(self::class, 'parent_id');
	}
}
Oct
02
1 month ago
Activity icon

Awarded Best Reply on Validation Should Show If Password Write Otherwise Should Not Show

You can check the documentation to create custom rules

https://laravel.com/docs/8.x/validation#custom-validation-rules

otherwise, try 'password' => ['sometimes', 'nullable', 'min:6']

Activity icon

Replied to Validation Should Show If Password Write Otherwise Should Not Show

You can check the documentation to create custom rules

https://laravel.com/docs/8.x/validation#custom-validation-rules

otherwise, try 'password' => ['sometimes', 'nullable', 'min:6']

Oct
01
1 month ago
Activity icon

Replied to How To Create Multidimensional Array With Loop

you can play with index

$array = [];

for ($i = 0; $i < 10; ++$i) {
	$array[$i] = [];
	
	for ($j = 0; $j < 10; ++$j) {
		$array[$i][$j] = "{$i}_{$j}";
	}
}
Sep
29
1 month ago
Activity icon

Replied to Create Model From String.

You can do that too

$test = app()->make(App\Model\User::class); or $test = app(App\Model\User::class);

Sep
24
2 months ago
Activity icon

Replied to Compare Sum Of Relational Column

Something like this ?

$countA = $model->relations()->where('column', '=', 'a')->count();
$countB = $model->relations()->where('column', '=', 'b')->count();

$countA < $countB ...
Sep
23
2 months ago
Activity icon

Replied to Anonymous Users After Deleting Account

You can create :

  • a Job to anynomize a user (last_name, email, ...)
  • a cron which get all user soft deleted after x days, and process job on them (take care to not anynomize user already anynomized)
Activity icon

Replied to Trying To Get Property 'email' Of Non-object (from .env File)

First, do not use env('MAIL_TO_ACTIVITY_ADDRESS'), use config('mail.activity_address'), and add in your config mail 'activity_address' => env('MAIL_TO_ACTIVITY_ADDRESS').

Clear the cache on your server.

For me, your error is in SiteActivityEmail class

Activity icon

Replied to How To Get WithCount And Relation Results At The Same Time?

Does this works ?

Thread
	::withCount('comments')
	->with(['comments' => function ($q) {
		$q
			->latests()
			->take(10);
	})
	->findOrFail(1063296);

Sep
14
2 months ago
Activity icon

Replied to I Want To Use OrderBy Throw This Array ?

First, remove your URL, because with the key, everyone can access your data.

Instead, insert a sample of the data, like

{
  "documents": [
    {
      "name": "......",
      "fields": {
        "created_at": {
          "timestampValue": "2020-08-27T14:41:40.508Z"
        }
      },
      "createTime": "2020-08-27T14:41:40.644088Z",
      "updateTime": "2020-09-08T10:48:50.207951Z"
    },
    {
      "name": "......",
      "fields": {
        "created_at": {
          "timestampValue": "2020-08-27T14:41:40.508Z"
        }
      },
      "createTime": "2020-08-27T14:41:40.644088Z",
      "updateTime": "2020-09-08T10:48:50.207951Z"
    },
    {
      "name": "......",
      "fields": {
        "created_at": {
          "timestampValue": "2020-08-27T14:41:40.508Z"
        }
      },
      "createTime": "2020-08-27T14:41:40.644088Z",
      "updateTime": "2020-09-08T10:48:50.207951Z"
    }
  ]
}

But what you want is to sort all tour results, so you have to check google api to check if exists an option to sort the result. If this option does not exists, put the results into a collection, then sort the collection (report to @pedroroccon message)

Sep
08
2 months ago
Activity icon

Awarded Best Reply on How To Prevent 504 Gate Way Time-out Error ( PHP Native ) ?

You can change the default php configuration (https://www.php.net/manual/fr/function.set-time-limit.php)

But you can do your process using queue https://laravel.com/docs/7.x/queues

And may be you can improve your code to be faster, using less memory

Activity icon

Replied to Difference Between HTTP_NOT_FOUND & HTTP_METHOD_NOT_ALLOWED

Oh yes, thank you

I think that 405 error is a little perfidious, but why not

Activity icon

Started a new Conversation Difference Between HTTP_NOT_FOUND & HTTP_METHOD_NOT_ALLOWED

Hello every one, I got a question

What is the difference between 404 (HTTP_NOT_FOUND) & 405 (HTTP_METHOD_NOT_ALLOWED) error ?

I define a route : Route::get("dogs/{dog}", 'App\Http\Controllers\Dogs\Show')->name('dogs.show');

When I make an HTTP call :

  • POST : dogs -> error 404
  • PUT : dogs/1 -> error 405

Thank you for your answers

Activity icon

Replied to How To Prevent 504 Gate Way Time-out Error ( PHP Native ) ?

You can change the default php configuration (https://www.php.net/manual/fr/function.set-time-limit.php)

But you can do your process using queue https://laravel.com/docs/7.x/queues

And may be you can improve your code to be faster, using less memory

Sep
05
2 months ago
Sep
01
2 months ago
Activity icon

Replied to A

    $roleIds = $request->input('roles');

    dd(count($roleIds));

    $roles = Role::withoutGlobalScopes()->whereIn('id', $roleIds)->get();

   // Must be equal to previous dd
    dd($roles->count());

    foreach($roles as $role) {
            $user->assignRole($role);
    }

    // OR 

    $roles->each(function (Role $role) use ($user) {
            $user->assignRole($role);
    });
Activity icon

Replied to How To Update Multiple Data And Can Also Add At The Same Time

You can improve tour code by doing this

public function update(Request $request, $id) {
    $qty= $request->input('qty');

    $delivery = Delivery::where('receipt_no','=',$id)->firstOrFail();

    $sumQty = array_sum($qty);

    $delivery->update(['qty' => $sumQty]);

    return $delivery;
}

But I do not understand what data you want to add :/

Activity icon

Replied to How To Make Efficient Query For $post->commnets And Comment->user

Your $post variable is already loaded, so if you can use the load method

public function detail(Post $post)
{
        $post->load(['comments', 'comments.user']);

	return view('home.detail')->with([
		'post' => $post
	]);
}
Activity icon

Replied to Razorpay Payment Gateway Implementation

Do you have Razorpay in your composer.json ?

Did you install it ?

if yes, make composer dump-autoload

Activity icon

Replied to Closure When The Where Comparison Is True - Possible?

In the official documention : https://laravel.com/docs/7.x/eloquent-relationships#querying-relationship-existence

Search : // Retrieve posts with at least ten comments containing words like foo%...

Activity icon

Replied to Run Command Inside A Job

You can check this documentation: https://laravel.com/docs/7.x/artisan#programmatically-executing-commands

Otherwise, you can create a job who perform your heavy machinery, and your command dispatch this job, like that you can dispatch this job anywhere you want :)

Aug
31
2 months ago
Activity icon

Awarded Best Reply on Column Not Found: 1054 Unknown Column '0' In 'field List'

Your $form_data is an array in an array; The solution :

$form_data = $request->only(['name', 'date', 'place']);
Activity icon

Replied to Get Count Of Items In Relationship

It's better to use $post->comments()->count(); than $post->comments->count();

The first one use the count of your database driver, the second one use the count of Collection, which means that you loaded all your post's comments beforehand, which is totally useless if just the count interests you; it could be worse if you have a lot of comments related to your post

Activity icon

Replied to Column Not Found: 1054 Unknown Column '0' In 'field List'

Your $form_data is an array in an array; The solution :

$form_data = $request->only(['name', 'date', 'place']);
Activity icon

Replied to Query Where Cluase Is Pulled From A Relation

Previous answer is the way to do, but to answer your question, it's because the closure does not inherit the $que variable

    auth()->user()->regions()->each(function($item,$key) use ($que) {
        $que->orWhere('region_id',$item);
    });
Aug
28
3 months ago
Activity icon

Replied to Made A Middleware To Check Ownership But It Works Randomly,

I do not know, you can try to debug with xdebug to check all the steps and figure it out.

And if you use $request->input('clinica_id') instead of $request->clinica_id

Activity icon

Replied to Made A Middleware To Check Ownership But It Works Randomly,

Remove in all your controller the argument type (Clinica) of $clinica_id variable

public function index(Request $request, $clinica_id)
{
    
    $servicios = $this->servicioRepository->getServiciosClinica($request, $clinica_id);
    
    return view('servicios.index',['servicios' => $servicios, 'clinica_id' => $clinica_id ]);
        
}
public function panel(Request $request, $clinica_id){

    $clinica = $this->clinicaRepository->find($clinica_id);

    if (empty($clinica)) {
        Flash::error('Clinica not found');

        return redirect(route('clinicas.index'));
    }
    return view('clinicas.panel', ['clinica', $clinica]);

}
Aug
25
3 months ago
Activity icon

Awarded Best Reply on Using Select In Vue Component?

You have to define your selected category in data function

{
  data: function () {
    return {
      selected: this.categories[0]
    }
  }
}

Then in your first option, just specify the value of the category selected

	<option selected="" :value="selected.id">{{ selected.name }}</option>

Activity icon

Replied to Restructuring Models And Parent Model

<?php

namespace App\Models;

class ModelA extends \Illuminate\Database\Eloquent\Model
{
    use \App\Concerns\CommonTrait;
}
<?php

namespace App\Models;


class ModelB extends \Illuminate\Database\Eloquent\Model
{
    use \App\Concerns\CommonTrait;
}
<?php

namespace App\Models;

class ModelC extends \Illuminate\Database\Eloquent\Model
{
    use \App\Concerns\CommonTrait;
}
<?php

namespace App\Concerns;

trait CommonTrait
{
    use TraitA;
    use TraitB;
    use TraitC;
    use TraitD;
}
Activity icon

Replied to Restructuring Models And Parent Model

You could :

  • extend your 3 classes by Illuminate\Database\Eloquent\Model
  • create a trait which use your 4 traits
  • each child class, use the trait previously created
Activity icon

Awarded Best Reply on JS NewClass Equivalent

Is that you want ?

const dbHeader = 'Date,Type,Account,Description,Debit/Credit,Reference'.split(',').map((Name, Value) => ({Name, Value}));
Activity icon

Replied to JS NewClass Equivalent

Can you solve this discussion please :)

Activity icon

Replied to Using Select In Vue Component?

You have to define your selected category in data function

{
  data: function () {
    return {
      selected: this.categories[0]
    }
  }
}

Then in your first option, just specify the value of the category selected

	<option selected="" :value="selected.id">{{ selected.name }}</option>

Activity icon

Replied to JS NewClass Equivalent

Is that you want ?

const dbHeader = 'Date,Type,Account,Description,Debit/Credit,Reference'.split(',').map((Name, Value) => ({Name, Value}));
Aug
22
3 months ago
Activity icon

Replied to Trying To Add A Join To A Model Query?

Be careful, you wrap your query twice with "%"

You can check this part of laravel documentation : https://laravel.com/docs/7.x/eloquent-relationships#querying-relationship-existence

Aug
20
3 months ago
Activity icon

Awarded Best Reply on Trying To Show Default Avatar Using If-else

@php($source = empty(auth()->user()->avatar) ? 'machine/default.png' : auth()->user()->avatar )
<img class="dp" src="/uploads/avatar/{{ $source }}">

in if condition, you forget to add () after user

Activity icon

Replied to Trying To Show Default Avatar Using If-else

@php($source = empty(auth()->user()->avatar) ? 'machine/default.png' : auth()->user()->avatar )
<img class="dp" src="/uploads/avatar/{{ $source }}">

in if condition, you forget to add () after user

Aug
19
3 months ago
Activity icon

Replied to Auth::user() Query Execution Time.

Do you have telescope or xdebug enabled ?

Aug
18
3 months ago
Activity icon

Awarded Best Reply on Eloquent Relationships

Article::with(['taggables.tags'])->get()

Is that correct for you ?

Activity icon

Replied to Eloquent Relationships

Article::with(['taggables.tags'])->get()

Is that correct for you ?

Activity icon

Started a new Conversation How To Get The Last Morph Relation From A BelongsTo Relationship On Morph Relation

Hello every one,

I have 3 models (book, line and invoice) A book can be invoiced multiple times An invoice can have 1 or plus lines A line is attach to a model through a poyloprhic relationship

Model Books:

  • id
  • label

Model Lines:

  • id
  • object_type
  • object_id
  • invoice_id

Model Invoices:

  • id
  • billed_at
  • payment_method

Books

| ID | LABEL                 |
------------------------------
| 1  | Harry Potter          |
| 2  | The Lord of the Rings |

Lines

| ID | OBJECT_TYPE | OBJECT_ID | INVOICE_ID |
---------------------------------------------
| 1  | book        | 1         | 1          |
| 2  | book        | 2         | 1          |
| 3  | book        | 1         | 2          |

Invoices

| ID | BILLED_AT  | PAYMENT_METHOD |
------------------------------------
| 1  | 2020-02-15 | stripe         |
| 2  | 2020-08-06 | cash           |

ONLY BY USING QUERY BUILDER (no collection)

I want Books where the last line invoiced (based on billed_at column ordered DESC) has been paid with stripe

How can I do that please, I'm stuck :/