Sinnbeck

Sinnbeck

Programmer at Aalund

Member Since 4 Years Ago

Odder

Experience Points
250,040
Total
Experience

0 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
136
Lessons
Completed
Best Reply Awards
380
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 50
250,040 XP
Jan
16
6 days ago
Activity icon

Awarded Best Reply on DisplayUsing() Not Working With Integers

Or simply tell it what to actually show

BelongsTo::make('Radio', 'gearratio', 'App\Nova\Gearratio')
    ->displayUsing(function ($name) {
        return 'i: '.$name->my_column;
    }),
Jan
10
1 week ago
Activity icon

Awarded Best Reply on Select A Post For One Day (Like Post Of The Day)

Simple solution

  1. Add a new table called post_of_the_day with a column for post_id and a column for date
  2. Add a scheduled task that gets a random post and adds it to the table, with todays date
  3. Get the post by using the id and date from the post_of_the_day table

You can even get a list of all previous post ids from the table, to ensure that the same one does not come again

Activity icon

Replied to AJAX For Laravel

If you want to learn vue then go with that. Learning ajax will be part of that process (as getting data from laravel will most likely be done using ajax). Unless you specifically need jquery, I personally would skip that.

If you absolutely want to learn some js before you begin, then start with some basic vanilla javascript.

Activity icon

Replied to Select A Post For One Day (Like Post Of The Day)

Simple solution

  1. Add a new table called post_of_the_day with a column for post_id and a column for date
  2. Add a scheduled task that gets a random post and adds it to the table, with todays date
  3. Get the post by using the id and date from the post_of_the_day table

You can even get a list of all previous post ids from the table, to ensure that the same one does not come again

Activity icon

Replied to Select A Post For One Day (Like Post Of The Day)

And how it the "Post of the day" determined? Do you select one at the start of the day or is it the first post made that day?

Activity icon

Replied to Hello I Am Getting Below Error On My Local System Laravel Setup.

Also if you can find the code that throws the error, then please post that as well.

Activity icon

Replied to Laravel Project - Php Mcrypt Extention Required

What are you running? Xampp, ubuntu, something else?

Activity icon

Replied to Sync

No it does not create a new table. It just updates that table with the relations between the two other tables

Activity icon

Replied to Sync

Based on the shown code I have no way of knowing.. Check either your database or the relationship definition of ProductCatalog

Activity icon

Awarded Best Reply on Php Artisan Migrate Not Working

Try running this from the terminal first

sudo apt-get install php7.3-mysql
Activity icon

Replied to Sync

Sync updates the table that holds the relation between the two tables

product_catelogues
product_categories
product_category_product_categolue <-this is the intermediate that holds the relations between the two other tables. The naming might be different.

And yes.. It just checks for a comma in the string. It seems redundant as explode works even if no comma is found

This should be fine, instead of the first 4 lines

$ids = explode(',', $request->product_category_id);
Activity icon

Replied to Php Artisan Migrate Not Working

Try running this from the terminal first

sudo apt-get install php7.3-mysql
Activity icon

Replied to Php Artisan Migrate Not Working

Create a file called phpinfo.php in public and put the following inside it

<?php
phpinfo();

Now call it in a browser and search for PDO. Can you find it?

Activity icon

Replied to Unable To Install Adldap2/adldap2-laravel Package

What if you just run composer install?

I installed it in a new laravel just yesterday without any problems (laravel 6.2 as well)

Activity icon

Replied to Unable To Install Adldap2/adldap2-laravel Package

Do you have a "require-dev" as well?

Jan
07
2 weeks ago
Activity icon

Awarded Best Reply on Current Date Is Being Displayed When Date Is Null

{{$employee->employment_date ? Carbon\Carbon::parse($employee->employment_date)->format('d-m-Y') : '' }}
Activity icon

Replied to Current Date Is Being Displayed When Date Is Null

{{$employee->employment_date ? Carbon\Carbon::parse($employee->employment_date)->format('d-m-Y') : '' }}
Jan
06
2 weeks ago
Activity icon

Replied to Master Detail Form With Just Two Tables

Also it would be a good idea to break down the task into sub tasks, and the you when you get stuck on a part you can ask.

This is like asking "How do I build my own car from scratch?". Instead you start by finding out how the engine works, then the how to form the chassis and so on.

So something like

  1. Add test data to the database and get it show as expected
  2. Find out how to dynamically add a text box to a form (hint: javascript eg. jquery) ...and so on
Activity icon

Replied to Some Questions About The Laravel Testing

You can give it a shot

php artisan optimize:clear
Activity icon

Replied to Laravel - Store Blade In DB And Render?

Did you notice the !! in the example by @sti3bas ? That is what ensures that blade does not escape the html.

Activity icon

Replied to Some Questions About The Laravel Testing

Any chance that you have set the $connection on the User model?

Activity icon

Replied to How Select Data By Weekly In Eloquent

Sorry but that does not make alot of sense. You want to get a sum based on only one row?

The sum would then be the "date" of just that row.

Activity icon

Replied to How Can I Lock A Laravel Template?

Do you mean for a complete laravel app? If so you could just zip it with a password.

Dec
18
1 month ago
Activity icon

Awarded Best Reply on Push Code To Server/ Deploy To Server

I dont know Alibaba cloud but perhaps you can describe their workflow.

If they just ssh into the server, cd into a directory, and git pull, then that can easily be automated using Envoy

https://laravel.com/docs/6.x/envoy

Dec
17
1 month ago
Activity icon

Awarded Best Reply on Problem With Calling Another Function From The Same Controller

You cannot have two POST routes with the exact same url. That wont work. Neither laravel nor your browser will know which route to take. It will always hit the first!

You need to do something like this.

Route::post('profile/session/{id}', '[email protected]')->name('session.save');
Route::post('profile/{id}', '[email protected]')->name('session.updateEverySessionByClick');
Activity icon

Replied to Display Records From Row Wise To Column Wise In Blade File Laravel

Something like this I would think

$headers = MyModel->distinct()->orderBy('subject')->get();
$groups = MyModel->orderBy('subject')->get()->groupBy('student');

//headers
@foreach($headers as $header)
    <th>{{  $header->subject }}</th>
Activity icon

Replied to Problem With Calling Another Function From The Same Controller

You cannot have two POST routes with the exact same url. That wont work. Neither laravel nor your browser will know which route to take. It will always hit the first!

You need to do something like this.

Route::post('profile/session/{id}', '[email protected]')->name('session.save');
Route::post('profile/{id}', '[email protected]')->name('session.updateEverySessionByClick');
Activity icon

Replied to Display Records From Row Wise To Column Wise In Blade File Laravel

You can group all results by the student

$groups = MyModel->get()->groupBy('student');

This will make a group of all results for each student. Be aware that you need to order the results properly to fit with the headers

@foreach($groups as $student => $results)
    <tr><td>{{$student}}</td>
    @foreach($results as $result)
         <td>{{$result->marks}}</td
    @endforeach
    </tr>
@endforeach
Activity icon

Awarded Best Reply on Visual Studio Code Blade Syntax Formatting

Seems that it was broken sometime in November

Check the first comment under this answer https://stackoverflow.com/a/52912771/1305117

Activity icon

Awarded Best Reply on Get All Product Related To Category Ids

Oh sorry forgot that it does not mutate

$productsOfThisCategory = collect([]);
        foreach($ProductCategories as $category) {
            $productsOfThisCategory = $productsOfThisCategory->merge($category->products);
        }
Activity icon

Replied to Visual Studio Code Blade Syntax Formatting

Seems that it was broken sometime in November

Check the first comment under this answer https://stackoverflow.com/a/52912771/1305117

Activity icon

Replied to How To Send Svg Via Laravel Controller ?

You would have to reimplement it all in javascript. You cannot run PHP async like that. PHP will run once the page is loaded and that is that.

Activity icon

Replied to Get All Product Related To Category Ids

try using unique

$productsOfThisCategory = $productsOfThisCategory->unique('id')->values()->all();
Activity icon

Replied to How To Check Comma Seprated Value In If Condition ?

Hehe thanks :) Alot of work getting there without watching videos. But as always, happy to help :)

Activity icon

Awarded Best Reply on How To Configure Setasign/fpdi-fpdf In Config/app.php ?

Like this https://laravel.com/docs/6.x/responses#creating-responses

return response($pdf->Output())
            ->header('Content-Type', 'application/pdf')
Activity icon

Awarded Best Reply on How To Check Comma Seprated Value In If Condition ?

The needle can take an array if I recall correct. Also your example should work if the list holds ALL values.

@if(in_array(['payment', 'userprofile'], explode(',', $users->enable_feature)))
Activity icon

Replied to Get All Product Related To Category Ids

Oh sorry forgot that it does not mutate

$productsOfThisCategory = collect([]);
        foreach($ProductCategories as $category) {
            $productsOfThisCategory = $productsOfThisCategory->merge($category->products);
        }
Activity icon

Replied to How To Configure Setasign/fpdi-fpdf In Config/app.php ?

Like this https://laravel.com/docs/6.x/responses#creating-responses

return response($pdf->Output())
            ->header('Content-Type', 'application/pdf')
Activity icon

Replied to How To Check Comma Seprated Value In If Condition ?

The needle can take an array if I recall correct. Also your example should work if the list holds ALL values.

@if(in_array(['payment', 'userprofile'], explode(',', $users->enable_feature)))
Activity icon

Replied to Get All Product Related To Category Ids

If you need to do it like that, this should work (if I knew more about you actual data, it could probably be done much simpler, by simply getting all product category Ids, and then running a whereIn on Product::

$productsOfThisCategory = collect([]);
        foreach($ProductCategories as $category) {
            $productsOfThisCategory->merge($category->products);
        }
Activity icon

Replied to How To Check Comma Seprated Value In If Condition ?

As there are multiple it can never be equals. Something like this should work

@if(in_array('payment', explode(',', $users->enable_feature)))
Activity icon

Replied to Get All Product Related To Category Ids

This part is calling a function (most likely a query builder)

 $category->products();

//Should be
 $category->products;

Also, I hope that you preload your relations? If not this will give you alot of database queries.

Activity icon

Replied to How To Configure Setasign/fpdi-fpdf In Config/app.php ?

You dont need to do anything. Just add a use in the top, and then new it up

use setasign\Fpdi\Fpdi;

//and inside the method
$pdf = new Fpdi();
//do stuff
return $pdf->Output();
Activity icon

Replied to Selecting Two Values From The Same Table But Under Different Conditions?

You would have to write some sort of alternative sql manually to do this.

Here is an example https://stackoverflow.com/questions/8986942/alternating-rows-based-on-a-value-of-a-column-in-mysql

Another solution would be to simply make 2 queries using first()

$student_promoted = Student::where('promoted', 1)->first();
$student_not_promoted = Student::where('promoted', 0)->first();
$students = collect([$student_promoted, $student_not_promoted]);
Activity icon

Replied to Property [owner] Does Not Exist On This Collection Instance

Also if it is a one to one relationship, you need to change to that

public function owner()
    {
            return $this->hasOne('App\Owner');
    }

@foreach($user as $users)
 {{$users->owner->id}} 
@endforeach
Dec
16
1 month ago
Activity icon

Replied to When And Why Use Each() Or Map() On A Collection?

Here is the code for each :)

//each
foreach ($this->items as $key => $item) {
            if ($callback($item, $key) === false) {
                break;
            }
        }
return $this;

//map
$keys = array_keys($this->items);

        $items = array_map($callback, $this->items, $keys);

        return new static(array_combine($keys, $items));
Activity icon

Replied to I Need Pagination With Chunk

Ok great. That is good to know.

You can select whichever you find working the best. I was just curious. It helps for when other have the same kind of issue