Chron

Chron

Member Since 1 Year Ago

Experience Points
16,180
Total
Experience

3,820 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
27
Lessons
Completed
Best Reply Awards
0
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 4
16,180 XP
Jul
11
2 days ago
Activity icon

Started a new Conversation Date And Time Picker

are there any date and time picker for laravel? I wanted to use the vanilla <input type="datetime"> but it is obsolete, I use firefox so datetime-local doesn't work yet either. I have tried tempus-dominus and daterangepicker but all of them just didn't fit my needs. I want a date and timepicker to have a min and max value that doesn't automatically fill the textbox once the page finished loading and can be opened always.

Jul
10
3 days ago
Activity icon

Started a new Conversation Tempus Dominus

Is there a way to set tempus dominus' maxDate without showing it in the textbox on load?

I have this:

 $('#date').datetimepicker({
    format: 'YYYY-MM-DD',
    minDate: (new Date('1950-01-01')),
    maxDate: (new Date('2000-12-31')),
  });

When I use useCurrent: false, yes, it doesn't show the date but it starts at the current date when opened the picker. I want it to hide the text on load and start at whatever maxDate was set to.

Jul
09
4 days ago
Activity icon

Started a new Conversation Relationships

For example, I have a model called User, is there a way to know all of the models related to it?

Jul
08
5 days ago
Activity icon

Started a new Conversation Default Value

Is there a way to have a default value without creating a record??

Activity icon

Started a new Conversation How Do Disable Foreign Key Checks In Tinker?

Is there a way to disable foreign key checks via tinker?

Jul
07
6 days ago
Activity icon

Started a new Conversation Is There A Way To Double Redirect?

Is there a way to hit the first route before going to the second redirection?

Activity icon

Replied to Conditional Redirect

Maybe double redirect it? Redirect first to product.create so that the url() records it then redirect again to people.create?

Activity icon

Replied to Conditional Redirect

Here's what I've done:


//ProductController
public function create() {

            $queryP = People::query();

            if($queryP->count()) {

                $people = $queryP->get();

                return view('product.create', compact('people'));

            }else {

                session()->flash('errorEmpty', 'You have to create people first.');       

                return redirect()->route('people.create');

            }
}

//PeopleController

public function store(Request $request) {

    	//......validation and storing of people records


        if (previous_route_is('product.create')) {

	   dd('hit');

        } else {

           return redirect()->route('people.create')->with('message', 'People added.');

       }

    }

I came from the /dashboard route, clicked the product to create but redirected to people.create route, which is what I wanted, but when I'm done creating people, it didn't passed the condition though, so it didn't dump and die.

Activity icon

Replied to Conditional Redirect

Where can I put the helper?

Activity icon

Started a new Conversation Conditional Redirect

For example, I have People, Accounts, and Products.

All of them have their controllers, models and tables.

But the user can only create products when both people and accounts are not empty.

So, the user will be redirected to route('people.create') if the user went to route('product.create') but peoples table is empty

So, If the user has completed creating people record, it will be redirected back to route('product.create').

Is there a way to check whether the user went to the page because of redirection or just a normal navigation?

Activity icon

Replied to How To Deal With Processes That Needed To Be Done In Sequence

I just saw it. What is that called?

Activity icon

Replied to How To Deal With Processes That Needed To Be Done In Sequence

No, I'm sorry if I was unclear. I'm only talking about the UI for the users.

Activity icon

Started a new Conversation How To Deal With Processes That Needed To Be Done In Sequence

How do you deal with processes that needed to be done in sequence?

For example, You need to create records for Person and Account first before making a record for Product.

I thought of using Bootstrap Breadcrumbs but Product is not the only one that depends on Person and Account.

Jul
06
1 week ago
Activity icon

Replied to Time With Date And After_or_equal Validation Returns An Error

I want it to be like this:

'date' =>      'required|date|after_or_equal:today',
'time' => 'required|date|after_or_equal:today,'.$request['date'].' '.$request['time']
Activity icon

Started a new Conversation Time With Date And After_or_equal Validation Returns An Error

I have this:

'date' =>      'required|date|after_or_equal:today',
'time' =>      'required|date_format:H:i|after_or_equal:today',

It's currently 13:42, 2020-07-06.

For example, I entered 2020-07-07, which is tomorrow, in date field, and 07:30 in time field, it returns an error that says the time must be a date after or equal to today., which is expected.

But is there a way to include the date when validating time?

So the time field would check the time with the date? So it will go to validation like this: 2020-07-07 07:30

Activity icon

Replied to Is There A Way To Convert A Full Date To Milliseconds?

For example, I got this

date: 2020-07-06 20:17:28.900295

I want to convert the whole date to milliseconds or something that can be compared to another date like that.

Activity icon

Started a new Conversation Is There A Way To Convert A Full Date To Milliseconds?

Is there a way to convert a now() to milliseconds?

Jul
05
1 week ago
Activity icon

Started a new Conversation Checkbox Validation

I have this:

<input type="checkbox" name="checkbox" id="checkbox" value="1"> Is this true?
$data = $request->validate([
    		'field1' => ['required'],
    		'field2' => ['required'],
            	'checkbox' => ['boolean']
  	     ]);

Model::create([
			'field1' => $data['field1'],
			'field2' => $data['field2'],
			'checkbox' => $data['checkbox'],
]);

Whenever I don't check the box, I get a validation error saying it must be boolean

Jul
03
1 week ago
Activity icon

Started a new Conversation Prevent User Access If There's No Record

Is there a way to prevent a user from accessing a route if there's no record? Is there a way to do all of that in one file? Kind of like how view composer works?

//view composer

view()->composer('*', function ($view){
            $view->with('user_count', User::count());
})
Jul
02
1 week ago
Activity icon

Started a new Conversation Is There A Way To Grab All The Html Tags Then Replace Them With Space?

The input is from a wysiwyg, is there a way to grab all the html tags then replace them with spaces?

Jun
30
1 week ago
Activity icon

Started a new Conversation Html Purifier Not Working

I'm using mewebstudio/purifier package

I have this in config/purifier.php

'HTML.Allowed'             => 'div,b,strong,i,em,u,ul,ol,li,p[style],br,span[style],img[width|height|src|style]',

As you can see, the img doesn't have alt, but the alt is still there when I die and dump the output. Is there a way to fix this?

Activity icon

Started a new Conversation Summernote On Laravel

Is there a way to automatically go to a next line when uploaded an image in the editor? Kind of like how trix works: https://trix-editor.org/

I saw a laravel-trix package but it must follow the naming convention, when I use the node trix version, the toolbar doesn't work, so I came back to summernote.

Activity icon

Started a new Conversation Remove Package From Node_modules

I already tried:

npm uninstall --save-dev [email protected]
npm uninstall [email protected]

But the package is still in node_modules, and I'm getting this warning:

npm WARN tempusdominus-bootstrap-4@5.1.2 requires a peer of [email protected] but none is installed. You must install peer dependencies yourself.

Jun
28
2 weeks ago
Activity icon

Started a new Conversation Is There A Way To Validate A Form As A Group?

For example, I have the input for name, age, role

Is there a way in form request to validate these fields as a group? Right now, I'm doing it like this:

'name' => ['required', new ValidationEx($this->name, $this->age, $this->role)],
'age' => ['required', new ValidationEx($this->name, $this->age, $this->role)],
'role' => ['required', new ValidationEx($this->name, $this->age, $this->role)],
Jun
25
2 weeks ago
Activity icon

Replied to Is There A Way To Eager Load Models With "has"?

Solved it. The has method should be whereHas without square brackets.

Model1::whereHas('models2', $callback)
    ->with(['models2' => $callback])
    ->get();
Activity icon

Replied to Is There A Way To Eager Load Models With "has"?

I tried it but I got an error:

Call to a member function getRelationExistenceQuery() on array
Activity icon

Started a new Conversation Is There A Way To Eager Load Models With "has"?

Is there a way to achieve this?

Model1::has(['models2' => function ($q) use ($userId) {
	$q->where('user_id', $userId);
}])->get();

For example, the userId is 4, I'll only get the records of Model1 with Model2 that has the userId of 4.

Activity icon

Started a new Conversation Out Of Range Value

Here's the data that I want to record:

Pay::create(['user_id'=>'1', 'amount'=> 2500.00])

I'm getting Numeric value out of range: 1264 Out of range value for column 'amount' at row 1 even though the column is set to decimal(4, 2). Is there a way to fix this?

Activity icon

Started a new Conversation Is There A Way To Have Two Lines Of Middleware In A Construct?

Like this?

public function __construct()
{
	$this->middleware('guest')->except('route1');
	$this->middleware(['auth', 'admin'])->except(['route2','route3']);
}
Jun
24
2 weeks ago
Activity icon

Replied to Is There A Way To Navigate Back?

It only returned to the base url.

For example, I'm in www.website.com/users/edit/1, then visited a non existent uri, I want it go back to www.website.com/users/edit/1 not www.website.com/

Activity icon

Started a new Conversation Is There A Way To Navigate Back?

Whenever the user visited a non-existent uri, I want the built in laravel error page to have a back button to go back to the previous link. Is there a way to do that?

Activity icon

Started a new Conversation Is There A Way To Prevent User From Accessing Non-GET Routes?

For example, I have these routes:

Route::post('user','[email protected]')->name('user.store');
Route::get('user/create','[email protected]')->name('user.create');
Route::get('user/{user}/edit','[email protected]')->name('user.edit');
Route::patch('user/{user}','[email protected]')->name('user.update');
Route::delete('user/delete','[email protected]')->name('user.destroy');

When I visit the /user which is a post route, I get an error:

The GET method is not supported for this route. Supported methods: POST.

Is there a way to prevent the user from accessing these routes instead of just throwing an error? Maybe navigate back if its not a get route.

Jun
23
2 weeks ago
Activity icon

Started a new Conversation Is Thre A Way To Convert An Integer To A Day Of The Week

For example:

Carbon::parse("1")->isoFormat('dddd'); //Monday
Activity icon

Started a new Conversation Accessing Models By Using The Pivot Table

Is there a way to access the relationships of the pivot table?

For example:

Model1 -> Pivot -> model 2
		     |
		     V
		model 3

Is there a way to make it like this?

Model1::with('pivot.' ['model2, model3'])->get()

So the output should be like this:

all: [
	Model1 {
		...
		pivot{
			model2 {
				...
			},
			model3 {
				...
			}
		}
	},
]
Activity icon

Started a new Conversation Is There A Validation For Duplicate Key Entry Combinations?

For example, Model1 id is 1 and Model2 id is 3, I know unique validation exists but it's only for one column, what if I want to check if the combination of keys are unique?

Jun
22
3 weeks ago
Activity icon

Started a new Conversation General Error: 1364 Field Column_id Doesn't Have A Default Value

Is there a way to add an additional value in a sync many to many?

I tried this but I'm getting General error: 1364 Field column_id doesn't have a default value error:

 $foo = Foo::where('name', $request['foo'])->first();

            foreach ($request['bars'] as $k => $bar) {
                $bars[$k] = Bar::firstOrCreate([
                    'name' => $bar
                ]);

                $user->bars()->sync([$bars[$k]->id, ['foo_id' => $foo->id]]);
	}
Activity icon

Replied to Is There A Way To Show Content When All The Css And Js Are Done Loading

The load event does help, but what if I'm using packages like select2? These packages only load after the load event, so you can still see the packages changing the components.

Activity icon

Replied to Is There A Way To Convert SVG With Css Animation To GIF?

@bobbybouwmann

I want to ask something. Is it better to have an svg that has a css animation with a size of ~8kb, or an animated gif with a size of 100-400kb?

Activity icon

Replied to Is There A Way To Convert SVG With Css Animation To GIF?

I'm getting an error of "Cannot read that as a ZipFile" when uploading the html file

Activity icon

Started a new Conversation Is There A Way To Convert SVG With Css Animation To GIF?

I have an SVG with a css animation embedded inside the file, is there a way to convert it to gif?

Jun
21
3 weeks ago
Activity icon

Replied to Multiple Data In An Array Validation

I'm having an error.

I have this in a rule:

'data' => ['required', 'array', new DataExists($this->data)],

When I changed the select name="data[]" to select name="data", it throws an "invalid argument for foreach" error from the DataExists rule. When it should stop progressing after the array validation failed.

Activity icon

Replied to Multiple Data In An Array Validation

It's still throwing the same error.

Activity icon

Started a new Conversation Multiple Data In An Array Validation

I have this example form.

<select name="data[]" multiple="multiple"/>
	@foreach($data as $d)
	<option value="{{ $d->id }}" {{ in_array($d->id, old('data') ? : []) ? 'selected' : ''}}>{{ $d->name }}</option>
	@endforeach
</select>

It accepts arrays, but what if the user decides to change the select name to only data and submitted it? It will then throw an error in_array() expects parameter 2 to be array, string given. Is there a way to still accept it as an array?

Activity icon

Replied to Is There A Way To Show Content When All The Css And Js Are Done Loading

Just tried it and it does the same as window.addEventListener('load', ()=>{}).

Jun
20
3 weeks ago
Activity icon

Replied to Validating Array Of Ids

I think we're not on the same page.

I'm trying to do this.

https://laravel.com/docs/5.8/validation#rule-unique

I don't need exists when updating data, I have unique because the data has to be different from the other data in the table. I also want to ignore the data if it is not changed. If I didn't used unique with an extra param, when I submitted an update form but didn't changed the data, it will throw an error.

Activity icon

Replied to Validating Array Of Ids

I'm not adding the ids as primary keys, I'm adding them as a data for a pivot table.

Activity icon

Replied to Validating Array Of Ids

I removed it and I'm getting The id has been taken validation error. I added that because it wouldn't throw an error if I submitted the data without updating it, but it doesn't work, I'm getting array to string conversion error.

Activity icon

Replied to Validating Array Of Ids

Also you have propably id as integer not a string.

Ohh, I didn't noticed that, sorry.

What is $this->data

That contains the array of ids when I'm updating data.