zaster

zaster

Member Since 4 Years Ago

Experience Points
15,100
Total
Experience

4,900 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
32
Lessons
Completed
Best Reply Awards
1
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 4
15,100 XP
Feb
05
2 weeks ago
Activity icon

Replied to Data Duplication(Slightly) As A Best Practice ?

@bobbybouwmann

For example

jobs table , invoices table payments table links with the companies table

If i take the payments table it would be easier if company_id is placed in it as a FK. (Then i can easily look at the payments table and identify which company has given the payment)

Feb
03
2 weeks ago
Activity icon

Started a new Conversation Many To Many Relationship Without Including Records To The Pivot Table

Invoice and ReceivePayment models have a many to many relationship and rarely we might receive a payment without an invoice. In that case No records will be entered to the pivot table. I am fine with that but is it the right way to do it?

Jan
29
3 weeks ago
Activity icon

Started a new Conversation Data Duplication(Slightly) As A Best Practice ?

I am using mysql database and have no idea about NoSQL Databases such as MongoDB

Theoretically, It is a best practice to design your tables avoiding data duplication as per relational database management concepts. But practically i feel that duplication of data gives a lot of flexibility (specially in medium to large projects, not that i have done many).

Since NoSQL Databases allows data duplication kind of techniques (correct me if i am wrong) , isn't it better to kind of not be So strict on avoiding data duplication in relational database management systems?

Jan
28
3 weeks ago
Activity icon

Started a new Conversation Huge List Of .json Files In Storage/debugbar

A huge list of .json files are submitted when i do a git commit through Visual Studio Code Editor

This drastically increase the size of the project.

Are these files essential ?

What should i do about them ?

Can i delete them ?

Activity icon

Replied to Many To Many - Attaching Multiple Records + Multiple Columns

@armancodes

I already tried that , it didn't work.

Activity icon

Started a new Conversation Many To Many - Attaching Multiple Records + Multiple Columns

 $qtys = SubJob::WhereIn('id', $selected_sub_job_ids)->pluck('qty');                
$rates = SubJob::WhereIn('id', $selected_sub_job_ids)->pluck('rate');                
$descriptions = SubJob::WhereIn('id', $selected_sub_job_ids)->pluck('description');                

$invoice->sub_jobs()->attach(($selected_sub_job_ids), ['qty' => $qtys], ['rate' => $rates], ['description' => $descriptions], ['visibility' => 1]);

I am getting this error

General error: 1366 Incorrect integer value: '[2000,2000]' for column 'qty' at row 1 

How can i get a single value from the qtys array and add to the pivot table

Activity icon

Started a new Conversation How Can I Minimize The Number Of Database Queries

InvoiceController.php

 $invoices = Invoice::with(['sub_jobs.user', 'sub_jobs.company'])->get();
        return view('employees.invoices.invoice', compact('invoices'));

invoice.blade.php

@foreach($invoices as $invoice)
                        
                            <tr>
                                <td>{{$invoice->id}}</td>
                               
                                <td><a href="{{route('employee.invoice.edit', $invoice->id)}}">{{$invoice->no}}</a></td> 
                                
                                <td>                                                                      
                                    {{$invoice->sub_jobs()->first()->user->name}}                             
                                </td>                                

                                <td>
                                    {{$invoice->sub_jobs()->first()->company->name}}
                                </td>  

                                <td>{{$invoice->date}}</td>

                                <td>{{$invoice->comp}}</td>

                                <td>@if($invoice->status == "1"){{"In Progress"}}@elseif($invoice->status == "0"){{"Pending"}}@endif</td>

                                {{-- <td>
                                    <a href="{{route('employee.job.edit', $invoice->sub_jobs()->first()->job->id)}}">{{$invoice->sub_jobs()->first()->job->id}}</a>                                    
                                </td> --}}
                            </tr>
                        @endforeach

I receive a lot of database queries for the above mentioned and need to minimize the number of database queries. I have used with but something is missing

Jan
27
3 weeks ago
Activity icon

Awarded Best Reply on Many To Many - Retrieve Multiple Records Through Pivot Table

@glenuk

$assigned_jobs = $invoice->sub_jobs->where('visibility', 0)->get('id');

Worked. Thanks.

Activity icon

Replied to Many To Many - Retrieve Multiple Records Through Pivot Table

@glenuk

$assigned_jobs = $invoice->sub_jobs->where('visibility', 0)->get('id');

Worked. Thanks.

Activity icon

Replied to Many To Many - Retrieve Multiple Records Through Pivot Table

@glenuk

Type error: Too few arguments to function Illuminate\Support\Collection::get(), 0 passed in
Activity icon

Started a new Conversation Many To Many - Retrieve Multiple Records Through Pivot Table

Invoice and SubJob Models have a Many to Many Relationship

I want to do something like this

$assigned_jobs = $invoice->sub_jobs->where('visibility', 0)->get();

The above doesn't work

but the below works

$assigned_jobs = $invoice->sub_jobs->where('visibility', 0)->first();

How can i get multiple records

Jan
26
3 weeks ago
Activity icon

Started a new Conversation 1 Website Hosted In 2 Hosting Accounts At The Same Time ?

I have hosted a website using the very basic droplet at Digital Ocean. What i want is to have the same setup at another hosting provider (E.g. Linode). The purpose is if something happens at digital ocean , i should be able to switch to Linode and continue work. 10 - 15 Minutes downtime is not a big issue.

Jan
23
4 weeks ago
Activity icon

Replied to 1 To M Query

@jbloomstrom

yes. it works with the ->get(); at the end. Thank you very much.

Activity icon

Started a new Conversation 1 To M Query

Job and SubJob has a 1 to M relationship

What i need is to get a list of jobs which has the below sub_jobs

        $sub_jobs = SubJob::where('user_id', $user_id)
                            ->where('user_company_id', $company_id)
                            ->where('comp', $comp)
                            ->get();
Jan
20
1 month ago
Activity icon

Replied to Deleting A Record From A Many To Many Relationship

@fylzero The M to M relationship is between Dispatch and Sub_Job

Not DispatchItem and Sub_Job

Am i missing something here ?

Activity icon

Replied to Saving Additional Data On A Pivot Table (Multiple Entries)

@manelgavalda I am expecting to save many rows depending on the length of the array

Activity icon

Replied to Saving Additional Data On A Pivot Table (Multiple Entries)

@manelgavalda I need to get the array values in to the integer fields

Activity icon

Started a new Conversation Saving Additional Data On A Pivot Table (Multiple Entries)

I am unable to insert $sub_job_qtys and $sub_job_description

1366 Incorrect integer value: '[1,1]' for column 'qty' at row 1
$sub_job_ids = $job->sub_jobs->pluck('id');
$sub_job_qtys = $job->sub_jobs->pluck('qty');
$sub_job_descriptions = $job->sub_jobs->pluck('description');


$dispatch->sub_jobs()->attach($sub_job_ids, ['qty' => $sub_job_qtys, 'description' => $sub_job_descriptions]);
Jan
16
1 month ago
Activity icon

Replied to Update Only If The Text Box Previous Value Was Blank

        if($po_item->comment == null && $request->input('comment') != null)
        {
            $po_item->update(['comment' => $request->input('comment')]);
        }

Worked for me

Activity icon

Started a new Conversation Update Only If The Text Box Previous Value Was Blank

I want to update the comment database field only with the first value entered

Ones something is written in the text box and submitted to the database , that value shouldn't be changed

I tried the below code with old but it doesn't give what i expect

    if($request->old('comment') == null) 
        {
            $po_item->update(['comment' => $request->input('comment')]);
        }
Jan
15
1 month ago
Activity icon

Started a new Conversation Deleting A Record From A Many To Many Relationship

Dispatch and SubJob has a M to M relationship and i have made DispatchItem to access the pivot table

When i tried

$dispatch_item->delete();

it deleted the record from the pivot table

it also deletes the record from the sub_jobs table (Which i should NOT do)

I was able to do the below and achieve deleting a pivot record only. But how could i do it using eloquent

public function destroy($id)
{
$dispatch_item = DispatchItem::find($id);   
//$dispatch_item->delete();
            DB::table('dispatch_subjob')->where('id', $id)->delete();
}
Jan
12
1 month ago
Activity icon

Started a new Conversation Index Page - Number Of Queries Increases When Number Of Records Increases

Number of queries increases when adding more POs Could you suggest a way of avoiding this situation

public function index()
    {                  
        //$pos = PO::all();
        $pos = PO::with(['po_items.vendor_company'])
        ->get();

        
        //Calculate the total of each po
        $po_totals = [];
        $vat_no = ''; //string declaration
        foreach ($pos as $po) 
        { 
            $po_total = 0;
 
            foreach ($po->po_items as $po_item) 
            {
                $item_total = $po_item->qty * $po_item->rate;
                $po_total += $item_total;                                           
            }
            
            if(is_null($po->po_items()->withTrashed()->first()))
            {
                $po_totals[$po->id] = $po_total;
            }       
            elseif($po->po_items()->withTrashed()->first()->vendor_company->vat_no && $po->comp == "PKL")
            {
                $po_totals[$po->id] = ($po_total + $po->vat);
            }                                                                            
            else
            {
                $po_totals[$po->id] = $po_total;
            }
            
        }                        
        return view('employees.pos.po', compact('pos', 'po_totals'));        
    }    
Jan
10
1 month ago
Activity icon

Started a new Conversation Undefined Variable

dd($request->comp);

returns a string but the below code gives an Undefined variable: comp error

public function store(Request $request)
{   
        
    //dd($request->comp);
        $vendor_company_id = $request->input('vendor_company_id'); 
        $vendor_company = Company::find($vendor_company_id);       
        $comp = $request->input('comp');
   
        
        
        $po_items = POItem::where('vendor_company_id', $vendor_company_id)
        ->where('status', 0)
        ->whereHas('cost_item', function ($query) {
            $query->whereHas('job', function ($query) {
                $query->where('status', 5);
                    $query->where('comp', $comp);
            });
        })->get();

...

}

Jan
09
1 month ago
Activity icon

Awarded Best Reply on 504 Gateway Time-out - When Generating Pdfs - In Production Environment

@emadiga in this instance, everything became back to normal after i informed the issue to the hosting provider.

Thanks for those links i will keep these mind when the next issue comes up

Activity icon

Replied to 504 Gateway Time-out - When Generating Pdfs - In Production Environment

@emadiga in this instance, everything became back to normal after i informed the issue to the hosting provider.

Thanks for those links i will keep these mind when the next issue comes up

Jan
07
1 month ago
Activity icon

Started a new Conversation 504 Gateway Time-out - When Generating Pdfs - In Production Environment

This error doesn't come all the time , but it comes most of the time when i am trying to generate a pdf

I am using laravel 5.5 and snappy pdf to generate pdfs

There is no issue when generating pdfs through development environment

Nov
12
3 months ago
Activity icon

Replied to "Class 'App\Events\NewJobHasRegisteredEvent' Not Found"

@sinnbeck very important link. Thank you very much.

Activity icon

Replied to "Class 'App\Events\NewJobHasRegisteredEvent' Not Found"

@sinnbeck and it worked.

Thank you very much.

Activity icon

Replied to "Class 'App\Events\NewJobHasRegisteredEvent' Not Found"

@sinnbeck

yes. I think that should be the answer.

use App\Events\NewJobHasRegisteredEvent;    

should be

use App\Events\newJobHasRegisteredEvent;

I will try that. It should work.

Activity icon

Replied to "Class 'App\Events\NewJobHasRegisteredEvent' Not Found"

@nakov

That is also included

NewJobHasRegisteredEvent.php

<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class newJobHasRegisteredEvent
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $job;
    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct($job)
    {
        $this->job = $job;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new PrivateChannel('channel-name');
    }
}
Activity icon

Replied to "Class 'App\Events\NewJobHasRegisteredEvent' Not Found"

EventServiceProvider.php

Looks like this

<?php

namespace App\Providers;

use App\Events\newJobHasRegisteredEvent;
use Illuminate\Support\Facades\Event;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

class EventServiceProvider extends ServiceProvider
{
    /**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
            newJobHasRegisteredEvent::class => [
            \App\Listeners\JobFormMailListener::class,
        ],
    ];

    /**
     * Register any events for your application.
     *
     * @return void
     */
    public function boot()
    {
        parent::boot();

        //
    }
}

Everything works perfectly fine in the development environment. When it comes to Production it gives this error

"Class 'App\Events\NewJobHasRegisteredEvent' not found"
Activity icon

Replied to "Class 'App\Events\NewJobHasRegisteredEvent' Not Found"

@sinnbeck I have already checked that. Not that either.

Activity icon

Replied to "Class 'App\Events\NewJobHasRegisteredEvent' Not Found"

@sinnbeck

Nope. I tried that , still the same error. I think it has something to with setting up queues in the production environment

Activity icon

Started a new Conversation "Class 'App\Events\NewJobHasRegisteredEvent' Not Found"

I am getting the below mentioned error only in the production environment

"Class 'App\Events\NewJobHasRegisteredEvent' not found"

jobcontroller.php

use App\Events\NewJobHasRegisteredEvent;

class JobController extends Controller
{

.
.
    public function store(Request $request)
    {

    .
    .
    event(new NewJobHasRegisteredEvent($job));
    return redirect('job');
     }
}

This runs fine in the development environment

I think its something to do with Queues in the production environment

because

php artisan queue:work 

shows nothing in the production environment

Nov
05
3 months ago
Activity icon

Started a new Conversation Is It A Good Idea To Develop All Web Based Projects Using REST API

Is it a good idea to develop all web based projects using REST API?

Nov
01
3 months ago
Activity icon

Started a new Conversation Php 7.2 To Php 7.3 - Upgrade

I thought of upgrading my php version from php 7.2 to php 7.3 because i need to start using the latest laravel version (Laravel 6)

Will this effect my older projects (uses Laravel 5.3 +)

Aug
17
6 months ago
Activity icon

Replied to Displaying Only Unique Values

@bobbybouwmann

I already tried that before posting my question

Example

1st sub_job->user->name = User A
2nd sub_job->user->name = User B
3rd sub_job->user->name = User B

The output should looks like

User A
User B
Activity icon

Started a new Conversation Displaying Only Unique Values

JobController.php

    public function index()
    {     
        $jobs = Job::all();
        return view('jobs.job',compact('jobs'));
     }

job.blade.php

 @foreach ($job->sub_jobs as $sub_job)                                                    
            {{$sub_job->user->name}}<br>                             
@endforeach

When there are multiple sub_jobs the name of the user will be repeated I only want to display the unique names