Sinnbeck

Sinnbeck

Programmer at Aalund

Member Since 4 Years Ago

Odder

Experience Points
76,660
Total
Experience

3,340 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
114
Lessons
Completed
Best Reply Awards
108
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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 16
76,660 XP
Oct
20
21 hours ago
Activity icon

Replied to Relation With Class Name

I am still not sure what the idea is doing this, but you can attach a relation manually if you want

$classname = get_class($this); //assuming this is called inside the model itself. Will return App/Models/Post
$data = DataModel::where('classname', $classname) ->get();
$this->setRelation('data', $data);

You can now access it at any time with $this->data (or $post->data if it is loaded like that at another place ).

I am unsure if this is what you want as this does not fall into default laravel usage and I am unsure of the purpose, I can only give you the tools to build it yourself. Hope it helps

Activity icon

Replied to How To Redirect To Another Page After Submitting The Form

That it isn't returning an actual redirect but just an array where the key happens to be named redirect

return ['redirect' => route('training_schedules.index')]; //this is just an array
Activity icon

Replied to Update Empty Checkboxes

If your question was solved by @jlrdw then please to remember to mark "best answer"

Activity icon

Replied to Eloquent Should I Use Where Or WhereHas

Looks fine. You can shorten it a little bit, but what you have now is great

$tasks = $tasks->where('task_status_id', '2')->where(function ($q) {
                $q->where('description', 'ilike', "%$this->querysearch%")
                    ->orWhereHas('teamleaderDeal', function ($query) {
                        $query->where('title', 'ilike', "%$this->querysearch%");
                    });
            });
Activity icon

Replied to Grab Images To Form A Carousel

You might be able to extract an array of image urls using preg_match_all.

preg_match_all( '@src="([^"]+)"@' , $html, $match );

$images = array_pop($match);
Activity icon

Replied to Relation With Class Name

So like this ?

$classname = get_class($this); //assuming this is called inside the model itself. Will return App/Models/Post
$data = DataModel::where('classname', $classname) ->get();
Activity icon

Replied to Typo In Directory Name That Is Not Detected By Apache But Detected By Ngnix

I think Mac OS X is the same as windows. Try creating test.txt and Test.txt in the same directory

Activity icon

Replied to Update Empty Checkboxes

Like I said. If you know the exact possible checkboxes, you can do it in php

Activity icon

Replied to Relation With Class Name

You can make the model and then load it something like this

$data = DataModel::find(1);
$classname = $data->classname; //eg. App/Models/Post
$model = resolve($classname); //the actual post model
Activity icon

Replied to Typo In Directory Name That Is Not Detected By Apache But Detected By Ngnix

Are you perhaps running windows locally and Linux live? Windows ignores case while Linux doesn't

Activity icon

Replied to Grab Images To Form A Carousel

How are the images related to the post? Just a url in some column?

Activity icon

Replied to Homestead Laravel/ui Npm Install Issue

Try

npm cache clean --force

Activity icon

Replied to Relation With Class Name

Welcome to the forum. Sorry I don't quite understand. Can you demonstrate how this is supposed to work?

If you are just looking for a simple relation it is documented here

https://laravel.com/docs/6.x/eloquent-relationships#one-to-many

Activity icon

Replied to Record Not Fetching From The Table.

As I understand it you need to get the correct items as an array? Sorry if I misunderstand

$items = Item::where('column', 42)->get();
return view('admin.accounts.print')
    ->with( [
         'account' => $account,
         'items' => $items
]);
Activity icon

Replied to Update Empty Checkboxes

Or you can use Javascript to iterate over your checkboxes and check their status. A simple html will not post anything if a checkbox is unchecked

If you have an array of items that are possible checkboxes you can also just remove each item from that array when it is checked. That should leave you with just the ones that are unchecked

Activity icon

Awarded Best Reply on From Login View To Calling Adminpanel With Foreach Loop

You don't set form1 to anything here?

public function login(request $request){ //dd($request->all()); 

return view('/adminpanel')->with('form1');
}

Maybe something like

public function login(request $request){
$form = Form::all();
return view('adminpanel', ['form1' =>$form] );
}
Activity icon

Replied to From Login View To Calling Adminpanel With Foreach Loop

I updated my post with example code

Activity icon

Replied to From Login View To Calling Adminpanel With Foreach Loop

You don't set form1 to anything here?

public function login(request $request){ //dd($request->all()); 

return view('/adminpanel')->with('form1');
}

Maybe something like

public function login(request $request){
$form = Form::all();
return view('adminpanel', ['form1' =>$form] );
}
Activity icon

Replied to Read Json In Ajax - Undefined

Got it working?

Activity icon

Awarded Best Reply on Read Json In Ajax - Undefined

Use first() instead of get() if you only need one record (It seems you do)

$dest = Destination::join('governorates','Destinations.governorate_id','=','governorates.id')->select('name','governorate')   
    ->first();
Activity icon

Replied to Make V-for Print Only One Object

So if the very first item is today you want to just render a message and not the rows?

Activity icon

Replied to How To Open The File Attached With The Document In New Windows

This should work then

<td><a href="{{ url('storage/categories/'. $c->th_attach }}">{{ $c->th_tran_no }}</a></td>
Activity icon

Awarded Best Reply on Form Without Data Is Also Inserting In Table

Simply add an if statement inside the foreach checking if $request->td_qty[$key] is filled

if($request->td_qty[$key]) {
  //save row
}
Activity icon

Replied to Read Json In Ajax - Undefined

Use first() instead of get() if you only need one record (It seems you do)

$dest = Destination::join('governorates','Destinations.governorate_id','=','governorates.id')->select('name','governorate')   
    ->first();
Activity icon

Replied to How To Open The File Attached With The Document In New Windows

If it is in the same table you don't need to get it again? Or do you mean th_tran_number points to another table with the file location?

If it is a separate table you can set up a relation and load it in your controller using with()

Activity icon

Replied to Form Without Data Is Also Inserting In Table

Simply add an if statement inside the foreach checking if $request->td_qty[$key] is filled

if($request->td_qty[$key]) {
  //save row
}
Activity icon

Replied to PHPUnit Lists Tests Vertically

Do you have dump(), echo or print in any of your tests?

Oct
19
1 day ago
Activity icon

Replied to Read Json In Ajax - Undefined

Try this instead of alert and open console (f12). Post the output. My guess is that it is under response.data

console.log(response)

Activity icon

Replied to Read Json In Ajax - Undefined

If you are getting an array but expect an object you might want to look into your controller instead. Like using first() instead of get()

Activity icon

Replied to What Is The Wrong When I Try To Seed??

These look fine. Can you post the seed that cases the error (if you can find it)

Activity icon

Replied to Which Data Type Supports Integer That Start With 0

Either use a string column or use integer and add the leading zeroes after getting them from the database

Activity icon

Replied to One Query To Get List Of Data And Total Count And Total Sum?

I don't think there is any way of doing that. You can think of the result of a query as a excel sheet. Each row is a result. So you would have the total on each and every line

Instead you can just get all rows, and calculate the numbers afterwards. You can then send these two numbers separately. You can get the data from the paginator using $results->items()

Hope it makes sense

Activity icon

Replied to JQuery Stop Checkbox Checked If Value Is Empty

Happy to help. You can fix the arrow issue like this

$("input[name='quantity[]']").bind('keyup change',function()
Activity icon

Replied to JQuery Stop Checkbox Checked If Value Is Empty

@nakov good idea. Just beware if the input is of type number. I don't think clicking the small up and down arrows count as keyup 😊

Activity icon

Replied to JQuery Stop Checkbox Checked If Value Is Empty

This is from the official documentation https://api.jquery.com/data/

$( "body" ).data( "foo", 52 );
$( "body" ).data( "foo" ); // 52

Since jQuery 1.4.3, data-* attributes are used to initialize jQuery data. An element's data-* attributes are retrieved the first time the data() method is invoked upon it, and then are no longer accessed or mutated (all values are stored internally by jQuery).

Activity icon

Replied to JQuery Stop Checkbox Checked If Value Is Empty

This alert is returning that? Or did you change it?

alert('Please Select Item Quantity');
Activity icon

Replied to JQuery Stop Checkbox Checked If Value Is Empty

The reason is most likely because data('quantity') is still 0. Try using my code example (it should change quantity correctly)

Activity icon

Replied to JQuery Stop Checkbox Checked If Value Is Empty

Ok try setting data like this

$("input[name='checkbox[]']").data("quantity",  $(this).val());
Activity icon

Replied to How Do I Make My HasOne Connection Cleaner?

This should load the query for you

$user->experience->points
Activity icon

Replied to JQuery Stop Checkbox Checked If Value Is Empty

So it show the alert the second time without you clicking the checkbox?

Activity icon

Replied to Use Str_replace To Replace Words Within String

str_replace supports arrays as search/replace

str_replace($wordList, $replaceList, $string);
Activity icon

Replied to Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

Wrap your links in url

{{ url('storage/'. $video->video_file) }}
Activity icon

Replied to Using Relationship Column In A Query

I am unsure why you have an array for a relationship. It is normally a method. Are you using a package for that to work?

Activity icon

Replied to Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

You are saving the videos in /videos but you try to find them in /queue/videos

$request->file('video_file')->store('queue/videos')
Activity icon

Replied to Multiple Queued Jobs With A Single Callback (1-n-1)

A simple approach would be to have a table with a date column, task Id and a completed column. When you dispatch a job you add a row with a task id for the coming task. Once the task is complete you set the row to complete and dispatch next and check if there are any incomplete. If everything is complete you dispatch the final job

  1. Set own job as complete
  2. Add row for each new job it will dispatch
  3. Dispatch jobs with the ID created in 2
  4. Check if all is complete (dispatch final job if true)