fbc

fbc

Member Since 3 Years Ago

Experience Points
9,110
Total
Experience

890 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
8
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 2
9,110 XP
Oct
30
18 hours ago
Activity icon

Replied to Pivot Table Woes.

@rodrigo.pedra @sinnbeck OK! I think I got it!

I had to use unsignedBigInteger instead of bigUnsignedInteger

Activity icon

Replied to Pivot Table Woes.

@rodrigo.pedra @sinnbeck I got error:

  SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key (SQL: create table `contact_estimate` (`contact_id` bigint unsigned not null auto_increment primary key, `estimate_id` bigint unsigned not null auto_increment primary key) default character set utf8 collate 'utf8_unicode_ci')

when I switched to this:

    public function up()
    {
        Schema::create('contact_estimate', function (Blueprint $table) {
            $table->bigIncrements('contact_id')->unsigned()->index();
            $table->foreign('contact_id')->references('id')->on('contacts')->onDelete('cascade');
            $table->bigIncrements('estimate_id')->unsigned()->index();
            $table->foreign('estimate_id')->references('id')->on('estimates')->onDelete('cascade');
            $table->primary(['contact_id', 'estimate_id']);
        });
    }
Activity icon

Replied to Pivot Table Woes.

yup just noticed that bt it still didn't fix my problem..

Activity icon

Started a new Conversation Pivot Table Woes.

I'm getting:

  SQLSTATE[HY000]: General error: 1005 Can't create table `estimatorstaging`.`contact_estimate` (errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter table `contact_estimate` add constraint `contact_estimate_contact_id_foreign` foreign key (`contact_id`) references `contact` (`id`) on delete cascade)

My pivot table looks like this:

...
    public function up()
    {
        Schema::create('contact_estimate', function (Blueprint $table) {
            $table->integer('contact_id')->unsigned()->index();
            $table->foreign('contact_id')->references('id')->on('contacts')->onDelete('cascade');
            $table->integer('estimate_id')->unsigned()->index();
            $table->foreign('estimate_id')->references('id')->on('estimates')->onDelete('cascade');
            $table->primary(['contact_id', 'estimate_id']);
        });
    }
...

my estimate table looks like this:

...
    public function up()
    {
        Schema::create('estimates', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->text('name');
            $table->integer('phase_id');
            $table->integer('status')->default(1);
            $table->integer('estimator_id');
            $table->integer('measurement_unit');
            $table->date('deadline_date');
            $table->time('deadline_time');

            $table->string('shipto_name')->nullable();
            $table->string('shipto_addr1')->nullable();
            $table->string('shipto_addr2')->nullable();
            $table->string('shipto_city')->nullable();
            $table->string('shipto_prov')->nullable();
            $table->string('shipto_pc')->nullable();
            $table->timestamps();
        });
    }
...

and my contact table looks like this:

...
    public function up()
    {
        Schema::create('contacts', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('company_id');
            $table->string('first_name');
            $table->string('last_name');
            $table->string('title');
            $table->string('email');
            $table->string('phone')->nullable();
            $table->string('ext')->nullable();
            $table->string('estimate_email')->nullable();
            // $table->json('contactrole_id')->nullable();
            $table->longText('notes')->nullable();
            $table->integer('project_assignment')->default(1);
            $table->boolean('active')->default(1);
            $table->timestamps();
        });
    }
...

I can't seem to figure out what I'm doing wrong.

Oct
28
2 days ago
Activity icon

Started a new Conversation Using Yajra Datatables Correctly For Deletes

My original delete syntax was as follow for every row in the table

...
                            <td class="row" style="text-align: right;">
                                <a href="{{route('project.edit',$project->id)}}">
                                    <i class="fas fa-cog"></i>
                                </a>
                                <form action="{{ route('project.destroy',$project->id) }}" method="POST">
                                    @csrf
                                    @method('DELETE')
                                    <button type="submit" class="btn btn-danger"
                                        onclick="return confirm('Are You Sure Want to Delete?')"
                                        style="padding: .0em !important;font-size: xx-small;">X</a>
                                </form>
                            </td>
...

I follow this guide: https://www.positronx.io/laravel-datatables-example/

and my resulting code in my controller looks like this:

...
    public function index(Request $request)
    {
        if ($request->ajax()) {
            $data = Project::latest()->get();
            return Datatables::of($data)
                ->addIndexColumn()
                ->addColumn('contractor', function ($row) {
                    $x = $row->contractor->first_name . ' ' . $row->contractor->last_name . ' (' . $row->contractor->company->name . ')';
                    return $x;
                })
                ->addColumn('action', function ($row) {
                    $btn = '<a href="javascript:void(0)" class="edit btn btn-success btn-sm">Edit</a> <a href="javascript:void(0)" class="delete btn btn-danger btn-sm">Delete</a>';
                    $x = '
                    <a href="{{route(\'project.edit\',$row->id)}}">
                    <i class="fas fa-cog"></i>
                    </a>
                    <form action="{{ route(\'project.destroy\',' . $row->id . ') }}" method="POST">
                    @csrf
                    @method(\'DELETE\')
                    <button type="submit" class="btn btn-danger"
                        onclick="return confirm(\'Are You Sure Want to Delete?\')"
                        style="padding: .0em !important;font-size: xx-small;">X</a>
                    </form>
                ';
                    return $x;
                })
                ->rawColumns(['action'])
                ->make(true);
        }

        return view('project.index');
    }
...

and my script in my index is as follows:

...
<script type="text/javascript">
    $(function () {
      
      var table = $('.yajra-datatable').DataTable({
          processing: true,
          serverSide: true,
          ajax: "{{ route('project.index') }}",
          columns: [
              {data: 'id', name: 'id'},
              {data: 'name', name: 'name'},
              {data: 'project_address', name: 'project_address'},
              {data: 'owner', name: 'owner'},
              {data: 'contractor', name: 'contractor'},
              {
                  data: 'action', 
                  name: 'action', 
                  orderable: true, 
                  searchable: true
              },
          ]
      });
      
    });
</script>
...

and my datatable section is as follows:

...
    <div class="col-md-12">
        <div class="card">
            {{-- <h2 class="mb-4">Laravel 7 Yajra Datatables Example</h2> --}}
            <table class="table table-bordered yajra-datatable">
                <thead>
                    <tr>
                        <th>No</th>
                        <th>Name</th>
                        <th>Project Address</th>
                        <th>Owner</th>
                        <th>Contractor</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                </tbody>
            </table>
        </div>
    </div>
...

It all works well except that my ACTION column displays "@CSRF" and "@METHOD" and my links don't work.

I can't understand what i'm doing wrong.

Oct
26
4 days ago
Activity icon

Replied to How Do I Query Through Many-to-Many?

@michaloravec Wow.. that is a wild query for me to interpret! Thanks.!

Activity icon

Replied to How Do I Query Through Many-to-Many?

@michaloravec @talinon How would I go about integrating that solution?

something like this? maybe?:

            $contacts = Contact::whereHas('roles', function ($query) {
                $query->where('id', 5);
            })->get();
            $data = $contacts->select("id", "company_id", "first_name", "last_name")
                ->where('first_name', 'LIKE', "%$search%")
                ->orWhere('last_name', 'LIKE', "%$search%")
                ->get();
Activity icon

Started a new Conversation How Do I Query Through Many-to-Many?

In my Contact.php I have the relationship defined as:

...
    public function roles()
    {
        return $this->belongsToMany('App\Models\contact\ContactRole');
    }
...

in my controller, I have this query:

...
            $data = Contact::select("id", "company_id", "first_name", "last_name")
                ->where('first_name', 'LIKE', "%$search%")
                ->orWhere('last_name', 'LIKE', "%$search%")
                ->get();
...

and I'm trying to get Contacts that have a roles()->where('id', 5)

My roles table has two column, 'id' and 'name'. Should I not be using the id to search and instead look for the matching name column? Pivots are so confusing to me. The matching name to 'id' record 5 is 'PM Contact'. I wonder if I should be trying to match that instead of the id. Help!

Edit: Normally I'd google it, but trying to query google for "laravel with examples" get me example sof laravel not specifically the "with" statements.

Oct
23
1 week ago
Activity icon

Replied to How To Concatenate Two Fields?

OMG! This is awesome!!! I'm gonna have to name my kids after you guys. Tykus Sinnbeck $lastname

Activity icon

Replied to How To Concatenate Two Fields?

When I'm typing a name in the box it says the results cannot be loaded.

Activity icon

Replied to How To Concatenate Two Fields?

hmm that doesn't seem to work for me. I added it to my model:

class Contact extends Model
{
    protected $fillable = [
        'company_id',
        'first_name',
        'last_name',
        'title',
        'email',
        'phone',
        'ext',
        'estimate_email',
        'notes',
        'project_assignment',
        'active',
    ];

    public function roles()
    {
        return $this->belongsToMany('App\Models\contact\ContactRole');
    }

    public function company()
    {
        return $this->hasOne('App\Models\contact\Company', 'id', 'company_id');
    }

    protected $appends = ['company_name'];
    public function getCompanyNameAttribute()
    {
        return $this->company->name;
    }
}

And used this:

<script type="text/javascript">
    $('.searchcontractor').select2({
      placeholder: 'Select an item',
      ajax: {
        url: '/project/searchcontractor',
        dataType: 'json',
        delay: 250,
        processResults: function (data) {
          return {
            results:  $.map(data, function (item) {
                  return {
                      text: item.first_name + ' ' + item.last_name + ' ' + item.company_name,
                      id: item.id
                  }
              })
          };
        },
        cache: true
      }
    });
</script>

what am I not considering?

Activity icon

Replied to How To Concatenate Two Fields?

How can I display attribute fields in my script. For example in my model I have this:

    public function company()
    {
        return $this->hasOne('App\Models\contact\Company', 'id', 'company_id');
    }

    public function getCompanyNameAttribute()
    {
        return $this->company->name;
    }

This is what I'm currenty trying and failing at:

<script type="text/javascript">
    $('.searchcontractor').select2({
      placeholder: 'Select an item',
      ajax: {
        url: '/project/searchcontractor',
        dataType: 'json',
        delay: 250,
        processResults: function (data) {
          return {
            results:  $.map(data, function (item) {
                  return {
                      text: item.first_name + ' ' + item.last_name + ' ' + item.CompanyName,
                      id: item.id
                  }
              })
          };
        },
        cache: true
      }
    });
</script>

My search route in my controller looks like this:

    public function searchcontractor(Request  $request)
    {
        $data = [];
        if ($request->has('q')) {
            $search = $request->q;
            $data = Contact::select("id", "first_name", "last_name")
                ->where('first_name', 'LIKE', "%$search%")
                ->orWhere('last_name', 'LIKE', "%$search%")
                ->get();
        }

        return response()->json($data);
    }
Activity icon

Started a new Conversation How To Concatenate Two Fields?

This is what I have now:

<script type="text/javascript">
    $('.searchcontractor').select2({
      placeholder: 'Select an item',
      ajax: {
        url: '/project/searchcontractor',
        dataType: 'json',
        delay: 250,
        processResults: function (data) {
          return {
            results:  $.map(data, function (item) {
                  return {
                      text: item.first_name,
                      id: item.id
                  }
              })
          };
        },
        cache: true
      }
    });
</script>

and this is what I'm tring to do:

                  return {
                      text: item.first_name.' '.item.last_name,
                      id: item.id
                  }

my php skills really do not help me with Javascript. :-(

Activity icon

Replied to How Do I Get More Than One Field Returned On Typeahead Searching?

Select2 is working really well.. I just need to figure out how to show both first and last names.

this is what I'm using:

<script type="text/javascript">
    $('.searchcontractor').select2({
      placeholder: 'Select an item',
      ajax: {
        url: '/project/searchcontractor',
        dataType: 'json',
        delay: 250,
        processResults: function (data) {
          return {
            results:  $.map(data, function (item) {
                  return {
                      text: item.first_name,
                      id: item.id
                  }
              })
          };
        },
        cache: true
      }
    });
</script>

and this is what i'm trying to do but not working:

                  return {
                      text: item.first_name.' '.item.last_name,
                      id: item.id
                  }
Activity icon

Started a new Conversation How Do I Get More Than One Field Returned On Typeahead Searching?

I've followed the guide below: https://appdividend.com/2018/04/27/laravel-typeahead-search-tutorial-with-example/

However, I want to show a field called first_name and last_name as they type. I also want to the search to match either first or last name.

I'm think I have the search figured out:

    public function result(Request  $request)
    {
        $result=Contact::
        where('first_name', 'LIKE', "%{$request->input('query')}%")
        ->orWhere('last_name', 'LIKE',  "%{$request->input('query')}%")
        ->get();
        return response()->json($result);
    }

but I'm still only getting first name showing in the result.

I also want the value of the chosen record be the ID field. I'm switching from dropdown select fields to typeahead serches.

                <div class="component-container form-group">
                    <label for="contractor_id">
                        Contractor
                    </label>
                    <div class="input-group">
                        <div class="input-group-prepend">
                            <span class="input-group-text">
                                <i class="fas fa-hard-hat"></i>
                            </span>
                        </div>
                        {{-- <select id="contractor_id" class="component form-control" name="contractor_id" required>
                            <option>
                                Pick a General Contractor....
                            </option>
                            @foreach ($project_managers->contacts as $contact)
                            <option value="{{$contact->id}}">
                                {{$contact->first_name}} {{$contact->last_name}} - {{$contact->company->name}}
                            </option>
                            @endforeach
                        </select> --}}
                        <input type="number" class="form-control" id="search" name="contractor_id">
                    </div>
                </div>

If you know of a helper or packagist plugin that might make this transition easier for me, any suggestions would be appreciated.

Oct
22
1 week ago
Activity icon

Replied to Acquiring The Location From Mobile Or Web Browser

Thanks for pointing me in the right direction!

Activity icon

Started a new Conversation Acquiring The Location From Mobile Or Web Browser

I wanted to write an app that had a location component. How would I best go about it? What are the recommended plugins I should use? Is this even possible with Laravel?

I'm trying to get functionality similar to facebook marketplace that allows you to see ads within 100km of your location.

Oct
08
3 weeks ago
Activity icon

Started a new Conversation Blade File Best Practices?

I've heard you are supposed to do all your logic in the controller and minimal in your blade. I have sort of a conundrum as I have two different bill types that use the same model and DBtable but different need to be displayed differently with the SHOW function.

Right now I have a whole bunch of IF statements to include or exclude the things I need to show depending on the type of bill it is. So you can imagine how complicated that blade file is.

Should I be making separate SHOW blades for each type, directing the function to the separate show files and making includes for those snippets they have in common?

Sep
29
1 month ago
Activity icon

Replied to How Do You Cycle Through A Set Of Numbers Though A Relationship

That was awesome!!! Pure genius.. Thanks!

Activity icon

Started a new Conversation How Do You Cycle Through A Set Of Numbers Though A Relationship

I'm to test for an amount at the end of various fields: So instead of writing it out manually for each cost code like this:

            if ($budget->estimate->CCTotal0001) {
                $budgetitem = new BudgetItem;
                $budgetitem->budget_id = $budget->id;
                $budgetitem->code = 1;
                $budgetitem->save();
            }

            if ($budget->estimate->CCTotal0100) {
                $budgetitem = new BudgetItem;
                $budgetitem->budget_id = $budget->id;
                $budgetitem->code = 100;
                $budgetitem->save();
            }

I'm trying a shortcut. I created a DB with an entry called 'code' for each costcode. However I'm using integer field and 0001 get recorded as 1 and so on. So I'm using substr to change it over but I don;t know how to tie it in.

        foreach (CostCode::all() as $costcode) {
            if ($budget->estimate->CCTotal substr("0000{$costcode->code}", -4)) {
                $budgetitem = new BudgetItem;
                $budgetitem->budget_id = $budget->id;
                $budgetitem->code = $costcode->code;
                $budgetitem->save();
            }
        }

Could someone lend a hand?

Sep
25
1 month ago
Activity icon

Started a new Conversation Multi-Tenant Package Recommendation

I've kinda coded my own multi-tenancy solutions in the past and it's been really great in some cases and others not so great.

However, so much of this code is now standard fare and available as a plugin. I'm porting my code to a standardized solution.

I discovered tenancy.dev put out one, but can't seem to find others. Are they the only one putting out a package or are there others?

Sep
15
1 month ago
Activity icon

Replied to Logic Exception

Yeh, I don't think I'm using any api requests for anything at the moment.. so I'll probably delete it.

Activity icon

Replied to Logic Exception

Yeah! I think that is where it's at:

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});
Activity icon

Replied to Logic Exception

Yes, I think it's happening when caching routes.. It's part of my update script.

Activity icon

Replied to Logic Exception

My routes look like this:

<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

// Auth::routes();
Auth::routes(['register' => false]);

Route::get('/', '[email protected]')->name('home');
Route::get('/home', '[email protected]')->name('home');

//Material Related Routes
Route::resource('material/profile', 'material\ProfileController');
Route::resource('material/vbarrierprod', 'material\VbarrierProdController');
Route::resource('material/insulationprod', 'material\InsulationProdController');
Route::resource('material/insupinprod', 'material\InsuPinProdController');
Route::resource('material/primerprod', 'material\PrimerprodController');
Route::resource('material/subgirtprod', 'material\SubgirtProdController');
Route::resource('setup/contractor', 'setup\ContractorController');
Route::resource('setup/vendor', 'setup\VendorController');

// Adding Jobs
Route::get('estimate/{estimate}/recalc', 'estimate\[email protected]')
    ->name('estimate.recalc');
Route::resource('estimate', 'estimate\EstimateController');
//For making Predefined Wall Types.
Route::resource('estimate.walltype', 'estimate\walltype\WallTypeController');
//For adding insulation to Predefined Wall Types.
Route::resource('estimate.walltype.insulation', 'estimate\walltype\WalltypeInsulationController');
//For adding vbarrier to Predefined Wall Types.
Route::resource('estimate.walltype.vbarrier', 'estimate\walltype\WalltypeVbarrierController');
//For adding subgirt to Predefined Wall Types.
Route::resource('estimate.walltype.subgirt', 'estimate\walltype\WalltypeSubgirtController');
//For adding sections to jobs
Route::get('estimate/{estimate}/section/{section}/recalc', 'estimate\[email protected]')
    ->name('section.recalc');
Route::resource('estimate.section', 'estimate\SectionController');
//For adding cladding to sections
Route::get(
    'estimate/{estimate}/section/{section}/cladding/createfromwalltype',
    'estimate\[email protected]'
)
    ->name('estimate.section.cladding.createfromwalltype');
Route::post(
    'estimate/{estimate}/section/{section}/cladding/storefromwalltype',
    'estimate\[email protected]'
)
    ->name('estimate.section.cladding.storefromwalltype');
Route::resource('estimate.section.cladding', 'estimate\CladdingController');
//For adding vapor barriers to cladding
Route::resource('estimate.section.cladding.vbarrier', 'estimate\VbarrierController');
//For adding insulation to cladding
Route::resource('estimate.section.cladding.insulation', 'estimate\InsulationController');
//For adding subgirt to cladding
Route::resource('estimate.section.cladding.subgirt', 'estimate\SubgirtController');
//This is more like a pivot table
Route::resource('estimate.estimatecontractor', 'estimate\EstimateContractorController');
Route::resource('estimate.detail', 'estimate\DetailController'); //Adding Details to Job

Route::get('estimate/{estimate}/detail/{detail}/trim/add-custom', 'estimate\[email protected]')
    ->name('trim.createcustom'); //Adding Custom Trim
Route::resource('estimate.detail.trim', 'estimate\TrimController'); //Adding trim to Details

Route::get('/estimate/getpdf/{estimate}', 'estimate\[email protected]')
    ->name('create.estimate-pdf');
Route::get('/estimate/getprintview/{estimate}', 'estimate\[email protected]')
    ->name('estimate.printview');

Route::post('/estimate/uploadafile', 'estimate\[email protected]')
    ->name('estimate.uploadafile');
Route::delete('/estimate/deleteafile/{token}', 'estimate\[email protected]')
    ->name('estimate.deleteafile');

Route::post('/estimate/detail/uploadafile', 'estimate\[email protected]')
    ->name('detail.uploadanimage');
Route::delete('/estimate/detail/deleteafile/{token}', 'estimate\[email protected]')
    ->name('detail.deleteanimage');

Route::resource('/estimate/equipment', 'estimate\EquipmentController');
Route::get('/estimate/equipment/create-equipment/{token}', 'estimate\[email protected]')
    ->name('equipment.createequip');

Route::resource('/estimate/freight', 'estimate\FreightController');
Route::get('/estimate/freight/create-freight/{token}', 'estimate\[email protected]')
    ->name('freight.createfreight');



//Project Related
Route::get('project/{project}/filemanager', 'project\[email protected]')
    ->name('project.filemanager'); // filemanager
Route::resource('project', 'project\ProjectController'); // Project Crud

//Budget Related
Route::resource('project.budget', 'project\BudgetController'); // Budget Crud

// Bill related
Route::post('project.bill.uploadafile', 'project\bill\[email protected]')
    ->name('bill.uploadafile');
Route::delete('project.bill.deleteafile/{token}', 'project\bill\[email protected]')
    ->name('bill.deleteafile');
Route::get('project/{project}/bill/createpb', 'project\bill\[email protected]')
    ->name('project.bill.createpb');
Route::get('project/{project}/bill/{bill}/approve', 'project\bill\[email protected]')
    ->name('project.bill.approve');
Route::get('project/{project}/bill/{bill}/unapprove', 'project\bill\[email protected]')
    ->name('project.bill.unapprove');
Route::get('project/{project}/bill/{bill}/createqbinvoice', 'project\bill\[email protected]')
    ->name('project.bill.createqbinvoice');
Route::resource('project.bill', 'project\bill\BillController'); // Bill Crud
Route::resource('project.bill.billitem', 'project\bill\BillItemController'); // BillItem Crud
Route::resource('project.bill.bcoitem', 'project\bill\BCOItemController'); // BCOItem Crud
Route::resource('project.bill.billrev', 'project\bill\BillRevController'); // BillRev Crud

//Change Order Related
Route::post(
    'project.changeorder.uploadafile',
    'project\changeorder\[email protected]'
)
    ->name('project.changeorder.uploadafile');
Route::delete(
    'project.changeorder.deleteafile/{token}',
    'project\changeorder\[email protected]'
)
    ->name('project.changeorder.deleteafile');
Route::get(
    'project/{project}/changeorder/{changeorder}/approve',
    'project\changeorder\[email protected]'
)
    ->name('project.changeorder.approve');
Route::get(
    'project/{project}/changeorder/{changeorder}/unapprove',
    'project\changeorder\[email protected]'
)
    ->name('project.changeorder.unapprove');
Route::resource('project.changeorder', 'project\changeorder\ChangeOrderController'); // ChangeOrder Crud
Route::resource('project.changeorder.coitem', 'project\changeorder\CoItemController'); // Change Order line Item Crud
Route::resource('project.changeorder.corev', 'project\changeorder\CoRevController'); // BillRev Crud

/* Purchase Order Retlated */
Route::post(
    'project.purchaseorder.uploadafile',
    'project\purchaseorder\[email protected]'
)
    ->name('project.purchaseorder.uploadafile');
Route::delete(
    'project.purchaseorder.deleteafile/{token}',
    'project\purchaseorder\[email protected]'
)
    ->name('project.purchaseorder.deleteafile');
Route::get(
    'project/{project}/purchaseorder/{purchaseorder}/approve',
    'project\purchaseorder\[email protected]'
)
    ->name('project.purchaseorder.approve');
Route::get(
    'project/{project}/purchaseorder/{purchaseorder}/unapprove',
    'project\purchaseorder\[email protected]'
)
    ->name('project.purchaseorder.unapprove');
Route::resource('project.purchaseorder', 'project\purchaseorder\PurchaseOrderController'); /* PurchaseOrder Crud */
Route::resource('project.purchaseorder.porev', 'project\purchaseorder\PoRevController'); /* PoRev Crud */
Route::resource('project.purchaseorder.poitem', 'project\purchaseorder\PoItemController'); /* PO line Item Crud */

/* RFI related */
Route::resource('project.rfi', 'project\rfi\RFIController'); /* RFI Crud */



/* Company Profile and Contact */
Route::resource('company', 'contact\CompanyController'); // Company Crud
Route::resource('company.contact', 'contact\ContactController'); // Contact Crud

Route::group(['prefix' => 'filemanager', 'middleware' => ['web', 'auth']], function () {
    \UniSharp\LaravelFilemanager\Lfm::routes();
});


Route::get('generator_builder', '\InfyOm\GeneratorBuilder\Controllers\[email protected]')
    ->name('io_generator_builder');

Route::get('field_template', '\InfyOm\GeneratorBuilder\Controllers\[email protected]')
    ->name('io_field_template');

Route::get(
    'relation_field_template',
    '\InfyOm\GeneratorBuilder\Controllers\[email protected]'
)
    ->name('io_relation_field_template');

Route::post('generator_builder/generate', '\InfyOm\GeneratorBuilder\Controllers\[email protected]')
    ->name('io_generator_builder_generate');

Route::post('generator_builder/rollback', '\InfyOm\GeneratorBuilder\Controllers\[email protected]')
    ->name('io_generator_builder_rollback');

Route::post(
    'generator_builder/generate-from-file',
    '\InfyOm\GeneratorBuilder\Controllers\[email protected]'
)->name('io_generator_builder_generate_from_file');

Activity icon

Started a new Conversation Logic Exception

When I run my migrations i get an error for an entry in my routes, but I can't quite figure out what is wrong. Everything continues to work as it should.


   LogicException 

  Unable to prepare route [api/user] for serialization. Uses Closure.

  at vendor/laravel/framework/src/Illuminate/Routing/Route.php:1150
    1146|      */
    1147|     public function prepareForSerialization()
    1148|     {
    1149|         if ($this->action['uses'] instanceof Closure) {
  > 1150|             throw new LogicException("Unable to prepare route [{$this->uri}] for serialization. Uses Closure.");
    1151|         }
    1152| 
    1153|         $this->compileRoute();
    1154| 

      +15 vendor frames 
  16  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

it seems the offending value is this:

Auth::routes(['register' => false]);

Sep
14
1 month ago
Activity icon

Replied to Upgrade From 6 To 7 Failed

Yeah,, I read your message went to the github repo for laravel 7 and pulled a fresh version of that file.

Activity icon

Replied to Upgrade From 6 To 7 Failed

It still failed. I got this:

$ rm -r vendor
$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 130 installs, 0 updates, 0 removals
  - Installing voku/portable-ascii (1.5.3): Loading from cache
  - Installing symfony/polyfill-ctype (v1.18.1): Loading from cache
  - Installing phpoption/phpoption (1.7.5): Loading from cache
  - Installing vlucas/phpdotenv (v4.1.8): Loading from cache
  - Installing symfony/css-selector (v5.1.5): Loading from cache
  - Installing tijsverkoyen/css-to-inline-styles (2.2.3): Loading from cache
  - Installing symfony/polyfill-php80 (v1.18.1): Loading from cache
  - Installing symfony/polyfill-mbstring (v1.18.1): Loading from cache
  - Installing symfony/var-dumper (v5.1.5): Loading from cache
  - Installing symfony/deprecation-contracts (v2.2.0): Loading from cache
  - Installing symfony/routing (v5.1.5): Loading from cache
  - Installing symfony/process (v5.1.5): Loading from cache
  - Installing symfony/polyfill-php72 (v1.18.1): Loading from cache
  - Installing paragonie/random_compat (v9.99.99): Loading from cache
  - Installing symfony/polyfill-php70 (v1.18.1): Loading from cache
  - Installing symfony/polyfill-intl-normalizer (v1.18.1): Loading from cache
  - Installing symfony/polyfill-intl-idn (v1.18.1): Loading from cache
  - Installing symfony/mime (v5.1.5): Loading from cache
  - Installing symfony/polyfill-intl-grapheme (v1.18.1): Loading from cache
  - Installing symfony/string (v5.1.5): Loading from cache
  - Installing phpdocumentor/reflection-common (2.2.0): Loading from cache
  - Installing webmozart/assert (1.9.1): Loading from cache
  - Installing phpdocumentor/type-resolver (1.3.0): Loading from cache
  - Installing phpdocumentor/reflection-docblock (5.2.1): Loading from cache
  - Installing psr/log (1.1.3): Loading from cache
  - Installing symfony/polyfill-php73 (v1.18.1): Loading from cache
  - Installing symfony/http-foundation (v5.1.5): Loading from cache
  - Installing psr/event-dispatcher (1.0.0): Loading from cache
  - Installing symfony/event-dispatcher-contracts (v2.2.0): Loading from cache
  - Installing symfony/event-dispatcher (v5.1.5): Loading from cache
  - Installing symfony/error-handler (v5.1.5): Loading from cache
  - Installing symfony/http-kernel (v5.1.5): Loading from cache
  - Installing symfony/finder (v5.1.5): Loading from cache
  - Installing psr/container (1.0.0): Loading from cache
  - Installing symfony/service-contracts (v2.2.0): Loading from cache
  - Installing symfony/console (v5.1.5): Loading from cache
  - Installing symfony/polyfill-iconv (v1.18.1): Loading from cache
  - Installing doctrine/lexer (1.2.1): Loading from cache
  - Installing egulias/email-validator (2.1.20): Loading from cache
  - Installing swiftmailer/swiftmailer (v6.2.3): Loading from cache
  - Installing brick/math (0.9.1): Loading from cache
  - Installing ramsey/collection (1.1.1): Loading from cache
  - Installing ramsey/uuid (4.1.1): Loading from cache
  - Installing psr/simple-cache (1.0.1): Loading from cache
  - Installing opis/closure (3.5.7): Loading from cache
  - Installing symfony/translation-contracts (v2.2.0): Loading from cache
  - Installing symfony/translation (v5.1.5): Loading from cache
  - Installing nesbot/carbon (2.39.2): Loading from cache
  - Installing monolog/monolog (2.1.1): Loading from cache
  - Installing league/mime-type-detection (1.4.0): Loading from cache
  - Installing league/flysystem (1.1.3): Loading from cache
  - Installing league/commonmark (1.5.5): Loading from cache
  - Installing dragonmantank/cron-expression (v2.3.0): Loading from cache
  - Installing doctrine/inflector (2.0.3): Loading from cache
  - Installing laravel/framework (v7.28.1): Loading from cache
  - Installing ralouphie/getallheaders (3.0.3): Loading from cache
  - Installing psr/http-message (1.0.1): Loading from cache
  - Installing guzzlehttp/psr7 (1.6.1): Loading from cache
  - Installing intervention/image (2.5.1): Loading from cache
  - Installing unisharp/laravel-filemanager (v2.1.0): Loading from cache
  - Installing sabberworm/php-css-parser (8.3.1): Loading from cache
  - Installing phenx/php-svg-lib (v0.3.3): Loading from cache
  - Installing phenx/php-font-lib (0.5.2): Loading from cache
  - Installing dompdf/dompdf (v0.8.6): Loading from cache
  - Installing barryvdh/laravel-dompdf (v0.8.7): Loading from cache
  - Installing balping/json-raw-encoder (v1.0.1): Loading from cache
  - Installing consoletvs/charts (6.5.5): Loading from cache
  - Installing fideloper/proxy (4.4.0): Loading from cache
  - Installing almasaeed2010/adminlte (v3.0.5): Loading from cache
  - Installing jeroennoten/laravel-adminlte (v3.4.4): Loading from cache
  - Installing dnoegel/php-xdg-base-dir (v0.1.1): Loading from cache
  - Installing nikic/php-parser (v4.9.1): Loading from cache
  - Installing psy/psysh (v0.10.4): Loading from cache
  - Installing laravel/tinker (v2.4.2): Loading from cache
  - Installing laravel/ui (v2.4.0): Loading from cache
  - Installing laravelcollective/html (v6.2.0): Loading from cache
  - Installing okipa/laravel-html-helper (1.4.0): Loading from cache
  - Installing okipa/laravel-bootstrap-components (2.2.3): Loading from cache
  - Installing orangehill/iseed (v2.6.4): Loading from cache
  - Installing quickbooks/v3-php-sdk (5.4.3): Loading from cache
  - Installing spinen/laravel-quickbooks-client (4.0.3): Loading from cache
  - Installing doctrine/event-manager (1.1.1): Loading from cache
  - Installing doctrine/cache (1.10.2): Loading from cache
  - Installing doctrine/dbal (2.10.4): Loading from cache
  - Installing symfony/filesystem (v5.1.5): Loading from cache
  - Installing seld/phar-utils (1.1.1): Loading from cache
  - Installing seld/jsonlint (1.8.2): Loading from cache
  - Installing justinrainbow/json-schema (5.2.10): Loading from cache
  - Installing composer/xdebug-handler (1.4.3): Loading from cache
  - Installing composer/spdx-licenses (1.5.4): Loading from cache
  - Installing composer/ca-bundle (1.2.8): Loading from cache
  - Installing composer/semver (1.7.0): Loading from cache
  - Installing composer/composer (1.10.13): Loading from cache
  - Installing barryvdh/reflection-docblock (v2.0.6): Loading from cache
  - Installing barryvdh/laravel-ide-helper (v2.8.1): Loading from cache
  - Installing scrivo/highlight.php (v9.18.1.2): Loading from cache
  - Installing filp/whoops (2.7.3): Loading from cache
  - Installing facade/ignition-contracts (1.0.1): Loading from cache
  - Installing facade/flare-client-php (1.3.5): Loading from cache
  - Installing facade/ignition (2.3.7): Loading from cache
  - Installing fzaninotto/faker (v1.9.1): Loading from cache
  - Installing laracasts/generators (1.2.0): Loading from cache
  - Installing hamcrest/hamcrest-php (v2.0.1): Loading from cache
  - Installing mockery/mockery (1.4.2): Loading from cache
  - Installing nunomaduro/collision (v4.2.0): Loading from cache
  - Installing sebastian/version (2.0.1): Loading from cache
  - Installing sebastian/type (1.1.3): Loading from cache
  - Installing sebastian/resource-operations (2.0.1): Loading from cache
  - Installing sebastian/recursion-context (3.0.0): Loading from cache
  - Installing sebastian/object-reflector (1.1.1): Loading from cache
  - Installing sebastian/object-enumerator (3.0.3): Loading from cache
  - Installing sebastian/global-state (3.0.0): Loading from cache
  - Installing sebastian/exporter (3.1.2): Loading from cache
  - Installing sebastian/environment (4.2.3): Loading from cache
  - Installing sebastian/diff (3.0.2): Loading from cache
  - Installing sebastian/comparator (3.0.2): Loading from cache
  - Installing phpunit/php-timer (2.1.2): Loading from cache
  - Installing phpunit/php-text-template (1.2.1): Loading from cache
  - Installing phpunit/php-file-iterator (2.0.2): Loading from cache
  - Installing theseer/tokenizer (1.2.0): Loading from cache
  - Installing sebastian/code-unit-reverse-lookup (1.0.1): Loading from cache
  - Installing phpunit/php-token-stream (3.1.1): Loading from cache
  - Installing phpunit/php-code-coverage (7.0.10): Loading from cache
  - Installing doctrine/instantiator (1.3.1): Loading from cache
  - Installing phpspec/prophecy (1.11.1): Loading from cache
  - Installing phar-io/version (2.0.1): Loading from cache
  - Installing phar-io/manifest (1.0.3): Loading from cache
  - Installing myclabs/deep-copy (1.10.1): Loading from cache
  - Installing phpunit/phpunit (8.5.8): Loading from cache
  - Installing squizlabs/php_codesniffer (3.5.6): Loading from cache
symfony/routing suggests installing symfony/config (For using the all-in-one router or any loader)
symfony/routing suggests installing symfony/yaml (For using the YAML loader)
symfony/routing suggests installing symfony/expression-language (For using expression matching)
symfony/routing suggests installing doctrine/annotations (For using the annotation loader)
paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)
symfony/event-dispatcher suggests installing symfony/dependency-injection
symfony/http-kernel suggests installing symfony/browser-kit
symfony/http-kernel suggests installing symfony/config
symfony/http-kernel suggests installing symfony/dependency-injection
symfony/service-contracts suggests installing symfony/service-implementation
symfony/console suggests installing symfony/lock
swiftmailer/swiftmailer suggests installing true/punycode (Needed to support internationalized email addresses, if ext-intl is not installed)
ramsey/uuid suggests installing ext-bcmath (Enables faster math with arbitrary-precision integers using BCMath.)
ramsey/uuid suggests installing ext-gmp (Enables faster math with arbitrary-precision integers using GMP.)
ramsey/uuid suggests installing ramsey/uuid-doctrine (Allows the use of Ramsey\Uuid\Uuid as Doctrine field type.)
ramsey/uuid suggests installing paragonie/random-lib (Provides RandomLib for use with the RandomLibAdapter)
symfony/translation suggests installing symfony/config
symfony/translation suggests installing symfony/yaml
monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
monolog/monolog suggests installing elasticsearch/elasticsearch (Allow sending log messages to an Elasticsearch server via official client)
monolog/monolog suggests installing php-amqplib/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib)
monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
monolog/monolog suggests installing ext-mongodb (Allow sending log messages to a MongoDB server (via driver))
monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server (via library))
monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome)
league/flysystem suggests installing league/flysystem-eventable-filesystem (Allows you to use EventableFilesystem)
league/flysystem suggests installing league/flysystem-rackspace (Allows you to use Rackspace Cloud Files)
league/flysystem suggests installing league/flysystem-azure (Allows you to use Windows Azure Blob storage)
league/flysystem suggests installing league/flysystem-webdav (Allows you to use WebDAV storage)
league/flysystem suggests installing league/flysystem-aws-s3-v2 (Allows you to use S3 storage with AWS SDK v2)
league/flysystem suggests installing league/flysystem-aws-s3-v3 (Allows you to use S3 storage with AWS SDK v3)
league/flysystem suggests installing spatie/flysystem-dropbox (Allows you to use Dropbox storage)
league/flysystem suggests installing srmklive/flysystem-dropbox-v2 (Allows you to use Dropbox storage for PHP 5 applications)
league/flysystem suggests installing league/flysystem-cached-adapter (Flysystem adapter decorator for metadata caching)
league/flysystem suggests installing league/flysystem-sftp (Allows you to use SFTP server storage via phpseclib)
league/flysystem suggests installing league/flysystem-ziparchive (Allows you to use ZipArchive adapter)
laravel/framework suggests installing ext-redis (Required to use the Redis cache and queue drivers (^4.0|^5.0).)
laravel/framework suggests installing aws/aws-sdk-php (Required to use the SQS queue driver, DynamoDb failed job storage and SES mail driver (^3.0).)
laravel/framework suggests installing guzzlehttp/guzzle (Required to use the HTTP Client, Mailgun mail driver and the ping methods on schedules (^6.3.1|^7.0).)
laravel/framework suggests installing league/flysystem-aws-s3-v3 (Required to use the Flysystem S3 driver (^1.0).)
laravel/framework suggests installing league/flysystem-cached-adapter (Required to use the Flysystem cache (^1.0).)
laravel/framework suggests installing league/flysystem-sftp (Required to use the Flysystem SFTP driver (^1.0).)
laravel/framework suggests installing moontoast/math (Required to use ordered UUIDs (^1.1).)
laravel/framework suggests installing nyholm/psr7 (Required to use PSR-7 bridging features (^1.2).)
laravel/framework suggests installing pda/pheanstalk (Required to use the beanstalk queue driver (^4.0).)
laravel/framework suggests installing predis/predis (Required to use the predis connector (^1.1.2).)
laravel/framework suggests installing pusher/pusher-php-server (Required to use the Pusher broadcast driver (^4.0).)
laravel/framework suggests installing symfony/cache (Required to PSR-6 cache bridge (^5.0).)
laravel/framework suggests installing symfony/psr-http-message-bridge (Required to use PSR-7 bridging features (^2.0).)
laravel/framework suggests installing wildbit/swiftmailer-postmark (Required to use Postmark mail driver (^3.0).)
guzzlehttp/psr7 suggests installing zendframework/zend-httphandlerrunner (Emit PSR-7 responses)
intervention/image suggests installing ext-imagick (to use Imagick based image processing.)
intervention/image suggests installing intervention/imagecache (Caching extension for the Intervention Image library)
unisharp/laravel-filemanager suggests installing ext-imagick (to use Imagick based image processing.)
dompdf/dompdf suggests installing ext-imagick (Improves image processing performance)
psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.)
psy/psysh suggests installing hoa/console (A pure PHP readline implementation. You'll want this if your PHP install doesn't already support readline or libedit.)
quickbooks/v3-php-sdk suggests installing guzzlehttp/guzzle (Uses Guzzle to make HTTP Requests)
doctrine/cache suggests installing alcaeus/mongo-php-adapter (Required to use legacy MongoDB driver)
composer/composer suggests installing ext-zip (Enabling the zip extension allows you to unzip archives)
barryvdh/reflection-docblock suggests installing dflydev/markdown (~1.0)
barryvdh/reflection-docblock suggests installing erusev/parsedown (~1.0)
filp/whoops suggests installing whoops/soap (Formats errors as SOAP responses)
facade/ignition suggests installing laravel/telescope (^3.1)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/phpunit suggests installing phpunit/php-invoker (^2.0.0)
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
Deprecation Notice: Class QuickBooksOnline\API\Data\IPPWrapper located in ./vendor/quickbooks/v3-php-sdk/src/Data/IPP.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in /usr/share/php/Composer/Autoload/ClassMapGenerator.php:201
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
PHP Fatal error:  Declaration of App\Exceptions\Handler::report(Exception $exception) must be compatible with Illuminate\Foundation\Exceptions\Handler::report(Throwable $e) in /home/xxx/LaravelRoot/app/app/Exceptions/Handler.php on line 35
PHP Stack trace:
PHP   1. {main}() /home/xxx/LaravelRoot/app/artisan:0
PHP   2. App\Console\Kernel->handle() /home/xxx/LaravelRoot/app/artisan:37
PHP   3. App\Console\Kernel->bootstrap() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:127
PHP   4. Illuminate\Foundation\Application->bootstrapWith() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:310
PHP   5. Illuminate\Foundation\Bootstrap\RegisterProviders->bootstrap() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:230
PHP   6. Illuminate\Foundation\Application->registerConfiguredProviders() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php:17
PHP   7. Illuminate\Foundation\ProviderRepository->load() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:604
PHP   8. Illuminate\Foundation\Application->register() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php:75
PHP   9. NunoMaduro\Collision\Adapters\Laravel\CollisionServiceProvider->register() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:627
PHP  10. Illuminate\Foundation\Application->make() /home/xxx/LaravelRoot/app/vendor/nunomaduro/collision/src/Adapters/Laravel/CollisionServiceProvider.php:72
PHP  11. Illuminate\Foundation\Application->make() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:781
PHP  12. Illuminate\Foundation\Application->resolve() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:637
PHP  13. Illuminate\Foundation\Application->resolve() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:796
PHP  14. Illuminate\Foundation\Application->build() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:691
PHP  15. Illuminate\Foundation\Application->Illuminate\Container\{closure:/home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:263-271}() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:805
PHP  16. Illuminate\Foundation\Application->resolve() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:269
PHP  17. Illuminate\Foundation\Application->resolve() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:796
PHP  18. Illuminate\Foundation\Application->build() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:691
PHP  19. ReflectionClass->__construct() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:809
PHP  20. spl_autoload_call() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:809
PHP  21. Composer\Autoload\ClassLoader->loadClass() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:809
PHP  22. Composer\Autoload\includeFile() /home/xxx/LaravelRoot/app/vendor/composer/ClassLoader.php:322
PHP  23. include() /home/xxx/LaravelRoot/app/vendor/composer/ClassLoader.php:444
PHP Fatal error:  Uncaught ReflectionException: Class App\Exceptions\Handler does not exist in /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:809
Stack trace:
#0 /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php(809): ReflectionClass->__construct()
#1 /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php(691): Illuminate\Container\Container->build()
#2 /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(796): Illuminate\Container\Container->resolve()
#3 /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php(269): Illuminate\Foundation\Application->resolve()
#4 /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php(805): Illuminate\Container\Container->Illuminate\Container\{closure}()
#5 /home/xxx/LaravelRoot/app/vendor/larave in /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 811
PHP Stack trace:
PHP   1. {main}() /home/xxx/LaravelRoot/app/artisan:0
PHP   2. App\Console\Kernel->handle() /home/xxx/LaravelRoot/app/artisan:37
PHP   3. App\Console\Kernel->bootstrap() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:127
PHP   4. Illuminate\Foundation\Application->bootstrapWith() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:310
PHP   5. Illuminate\Foundation\Bootstrap\RegisterProviders->bootstrap() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:230
PHP   6. Illuminate\Foundation\Application->registerConfiguredProviders() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php:17
PHP   7. Illuminate\Foundation\ProviderRepository->load() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:604
PHP   8. Illuminate\Foundation\Application->register() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php:75
PHP   9. NunoMaduro\Collision\Adapters\Laravel\CollisionServiceProvider->register() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:627
PHP  10. Illuminate\Foundation\Application->make() /home/xxx/LaravelRoot/app/vendor/nunomaduro/collision/src/Adapters/Laravel/CollisionServiceProvider.php:72
PHP  11. Illuminate\Foundation\Application->make() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:781
PHP  12. Illuminate\Foundation\Application->resolve() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:637
PHP  13. Illuminate\Foundation\Application->resolve() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:796
PHP  14. Illuminate\Foundation\Application->build() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:691
PHP  15. Illuminate\Foundation\Application->Illuminate\Container\{closure:/home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:263-271}() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:805
PHP  16. Illuminate\Foundation\Application->resolve() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:269
PHP  17. Illuminate\Foundation\Application->resolve() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:796
PHP  18. Illuminate\Foundation\Application->build() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:691
PHP  19. ReflectionClass->__construct() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:809
PHP  20. spl_autoload_call() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:809
PHP  21. Composer\Autoload\ClassLoader->loadClass() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:809
PHP  22. Composer\Autoload\includeFile() /home/xxx/LaravelRoot/app/vendor/composer/ClassLoader.php:322
PHP  23. include() /home/xxx/LaravelRoot/app/vendor/composer/ClassLoader.php:444
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255
Activity icon

Started a new Conversation Upgrade From 6 To 7 Failed

I replaced the dependencies and did a composer update and got this:

> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
PHP Fatal error:  Declaration of App\Exceptions\Handler::report(Exception $exception) must be compatible with Illuminate\Foundation\Exceptions\Handler::report(Throwable $e) in /home/xxx/LaravelRoot/app/app/Exceptions/Handler.php on line 35
PHP Stack trace:
PHP   1. {main}() /home/xxx/LaravelRoot/app/artisan:0
PHP   2. App\Console\Kernel->handle() /home/xxx/LaravelRoot/app/artisan:37
PHP   3. App\Console\Kernel->bootstrap() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:127
PHP   4. Illuminate\Foundation\Application->bootstrapWith() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:310
PHP   5. Illuminate\Foundation\Bootstrap\RegisterProviders->bootstrap() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:230
PHP   6. Illuminate\Foundation\Application->registerConfiguredProviders() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php:17
PHP   7. Illuminate\Foundation\ProviderRepository->load() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:604
PHP   8. Illuminate\Foundation\Application->register() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php:75
PHP   9. NunoMaduro\Collision\Adapters\Laravel\CollisionServiceProvider->register() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:627
PHP  10. Illuminate\Foundation\Application->make() /home/xxx/LaravelRoot/app/vendor/nunomaduro/collision/src/Adapters/Laravel/CollisionServiceProvider.php:72
PHP  11. Illuminate\Foundation\Application->make() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:781
PHP  12. Illuminate\Foundation\Application->resolve() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:637
PHP  13. Illuminate\Foundation\Application->resolve() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:796
PHP  14. Illuminate\Foundation\Application->build() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:691
PHP  15. Illuminate\Foundation\Application->Illuminate\Container\{closure:/home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:263-271}() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:805
PHP  16. Illuminate\Foundation\Application->resolve() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:269
PHP  17. Illuminate\Foundation\Application->resolve() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:796
PHP  18. Illuminate\Foundation\Application->build() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:691
PHP  19. ReflectionClass->__construct() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:809
PHP  20. spl_autoload_call() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:809
PHP  21. Composer\Autoload\ClassLoader->loadClass() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:809
PHP  22. Composer\Autoload\includeFile() /home/xxx/LaravelRoot/app/vendor/composer/ClassLoader.php:322
PHP  23. include() /home/xxx/LaravelRoot/app/vendor/composer/ClassLoader.php:444
PHP Fatal error:  Uncaught ReflectionException: Class App\Exceptions\Handler does not exist in /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:809
Stack trace:
#0 /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php(809): ReflectionClass->__construct()
#1 /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php(691): Illuminate\Container\Container->build()
#2 /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(796): Illuminate\Container\Container->resolve()
#3 /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php(269): Illuminate\Foundation\Application->resolve()
#4 /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php(805): Illuminate\Container\Container->Illuminate\Container\{closure}()
#5 /home/xxx/LaravelRoot/app/vendor/larave in /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 811
PHP Stack trace:
PHP   1. {main}() /home/xxx/LaravelRoot/app/artisan:0
PHP   2. App\Console\Kernel->handle() /home/xxx/LaravelRoot/app/artisan:37
PHP   3. App\Console\Kernel->bootstrap() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:127
PHP   4. Illuminate\Foundation\Application->bootstrapWith() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:310
PHP   5. Illuminate\Foundation\Bootstrap\RegisterProviders->bootstrap() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:230
PHP   6. Illuminate\Foundation\Application->registerConfiguredProviders() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php:17
PHP   7. Illuminate\Foundation\ProviderRepository->load() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:604
PHP   8. Illuminate\Foundation\Application->register() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php:75
PHP   9. NunoMaduro\Collision\Adapters\Laravel\CollisionServiceProvider->register() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:627
PHP  10. Illuminate\Foundation\Application->make() /home/xxx/LaravelRoot/app/vendor/nunomaduro/collision/src/Adapters/Laravel/CollisionServiceProvider.php:72
PHP  11. Illuminate\Foundation\Application->make() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:781
PHP  12. Illuminate\Foundation\Application->resolve() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:637
PHP  13. Illuminate\Foundation\Application->resolve() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:796
PHP  14. Illuminate\Foundation\Application->build() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:691
PHP  15. Illuminate\Foundation\Application->Illuminate\Container\{closure:/home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:263-271}() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:805
PHP  16. Illuminate\Foundation\Application->resolve() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:269
PHP  17. Illuminate\Foundation\Application->resolve() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:796
PHP  18. Illuminate\Foundation\Application->build() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:691
PHP  19. ReflectionClass->__construct() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:809
PHP  20. spl_autoload_call() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:809
PHP  21. Composer\Autoload\ClassLoader->loadClass() /home/xxx/LaravelRoot/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:809
PHP  22. Composer\Autoload\includeFile() /home/xxx/LaravelRoot/app/vendor/composer/ClassLoader.php:322
PHP  23. include() /home/xxx/LaravelRoot/app/vendor/composer/ClassLoader.php:444
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255

What am I doing wrong? The instructions on the upgrade page just say to replace dependencies in composer.json

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.2",
        "barryvdh/laravel-dompdf": "^0.8.6",
        "consoletvs/charts": "6.*",
        "doctrine/dbal": "^2.10",
        "fideloper/proxy": "^4.0",
        "jeroennoten/laravel-adminlte": "^3.0",
        "laravel/framework": "^7.0",
        "laravel/tinker": "^2.0",
        "laravel/ui": "^2.4",
        "laravelcollective/html": "^6.0",
        "okipa/laravel-bootstrap-components": "^2.0",
        "orangehill/iseed": "^2.6",
        "spinen/laravel-quickbooks-client": "^4.0",
        "unisharp/laravel-filemanager": "^2.1"
    },
    "require-dev": {
        "barryvdh/laravel-ide-helper": "^2.7",
        "facade/ignition": "^2.0",
        "fzaninotto/faker": "^1.4",
        "laracasts/generators": "^1.1",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^4.1",
        "phpunit/phpunit": "^8.5",
        "squizlabs/php_codesniffer": "^3.5"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

Aug
26
2 months ago
Activity icon

Started a new Conversation How Do You Update A Value In An Array?

I'm trying to update the value of FLATS for each of the colors in my array.

This is my function.

    public function getDetailsByColorAttribute()
    {
        /* Setup collection to receive the colors */
        $colors = collect();

	/* gather the names of all the colors */
        foreach ($this->details as $detail) {
            foreach ($detail->trims as $trim) {
                $colors->push(['name' => $trim->color, 'flats' => 0]);
            }
        }
        //remove duplicate ids
        $colors = $colors->unique('name');

        foreach ($colors as $color) {
            $x = 0;
            foreach ($this->details as $detail) {
                foreach ($detail->trims()->where('color', $color['name'])->get() as $trim) {
                    $x = $x + $trim->Flats;
                }
            }

            Arr::set($color, 'flats', $x);
        }
        dd($colors);
    }

My results are always like this:

Illuminate\Support\Collection {#725 ▼
  #items: array:2 [▼
    0 => array:2 [▼
      "name" => "12"
      "flats" => 0
    ]
    1 => array:2 [▼
      "name" => "White"
      "flats" => 0
    ]
  ]
}

Update: It seems like it is changing it within the FOREACH loop but the update is not surviving the end of the loop.

Aug
25
2 months ago
Activity icon

Replied to Is It Possible To Use Array With An Operator?

Wow that one is almost ineligible to me.

Activity icon

Started a new Conversation Is It Possible To Use Array With An Operator?

Is it possible to replace this:

            if ($item->costcode->type == 'lw') {
                $x = $x + $item->Amount;
            }
            if ($item->costcode->type == 'll') {
                $x = $x + $item->Amount;
            }

with something like this:

            if ($item->costcode->type == ['lw', 'll']) {
                $x = $x + $item->Amount;
            }

basically if equal 'lw' OR 'll'

Is something like this possible?

Aug
07
2 months ago
Activity icon

Started a new Conversation Collections: Unique By Combinations Of Multiple Fields Possible?

I have a collection as so:

Illuminate\Support\Collection {#846 ▼
  #items: array:8 [▼
    0 => App\Models\estimate\section\Subgirt {#955 ▼
      #fillable: array:9 [▶]
      #connection: "mysql"
      #table: "subgirts"
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:13 [▼
        "id" => 505
        "cladding_id" => 283
        "subgirt_id" => 2
        "direction" => 1
        "spacing" => 12
        "guage" => 14
        "girth" => 2
        "folds" => 12
        "flat_size" => 1
        "strapping_size" => null
        "created_at" => "2020-06-22 10:33:05"
        "updated_at" => "2020-06-22 10:33:05"
        "label" => "4x2"
      ]
      #original: array:13 [▶]
      #changes: []
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #dispatchesEvents: []
      #observables: []
      #relations: []
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #guarded: array:1 [▶]
    }
    1 => App\Models\estimate\section\Subgirt {#938 ▶}
    2 => App\Models\estimate\section\Subgirt {#953 ▶}
    3 => App\Models\estimate\section\Subgirt {#956 ▶}
    4 => App\Models\estimate\section\Subgirt {#881 ▶}
    5 => App\Models\estimate\section\Subgirt {#962 ▶}
    6 => App\Models\estimate\section\Subgirt {#963 ▶}
    7 => App\Models\estimate\section\Subgirt {#966 ▶}
  ]
}

I used to use:

        $subgirts = $subgirts->unique('subgirt_id');

to get the unique records, but now I need unique combinations of 'subgirt_id' and 'label'.

For example I need to be able to do something like this:

$collection = collect([
    ['name' => 'iPhone 6', 'brand' => 'Apple', 'type' => 'phone'],
    ['name' => 'iPhone 5', 'brand' => 'Apple', 'type' => 'phone'],
    ['name' => 'Apple Watch', 'brand' => 'Apple', 'type' => 'watch'],
    ['name' => 'Galaxy S6', 'brand' => 'Samsung', 'type' => 'phone'],
    ['name' => 'Galaxy Gear', 'brand' => 'Samsung', 'type' => 'watch'],
]);

$unique = $collection->unique('brand', 'type');

$unique->values()->all();

/*
    [
        ['name' => 'iPhone 6', 'brand' => 'Apple', 'type' => 'phone'],
    ['name' => 'Apple Watch', 'brand' => 'Apple', 'type' => 'watch'],
        ['name' => 'Galaxy S6', 'brand' => 'Samsung', 'type' => 'phone'],
    ['name' => 'Galaxy Gear', 'brand' => 'Samsung', 'type' => 'watch'],
    ]
*/
Jul
30
3 months ago
Activity icon

Replied to How Do I Group The Similiar Lines And Total Them?

ouch! having to read that almost gave me headache. I figured it out in a roundabout way. Here is what I did in my model:

<?php

namespace App\Models\project;

use App\Models\material\Profile;
use Illuminate\Database\Eloquent\Model;

class Budget extends Model
{
    protected $fillable = [
        'project_id',
        'estimate_id',
    ];

    public function estimate()
    {
        return $this->hasOne('App\Models\estimate\Estimate', 'id', 'estimate_id');
    }


    public function getRoofProfilesAttribute()
    {
        //create collection
        $profile_ids = collect();

        //Gather all the roofing profiles used in the Project
        foreach ($this->estimate->sections()->where('sectiontype_id', 0)->get() as $section) {
            foreach ($section->claddings as $cladding) {
                // Add the profile ID to the list
                $profile_ids->push($cladding->profile->id);
            }
        }
        //remove duplicate ids
        $profile_ids = $profile_ids->unique();

        //gather the profiles
        $profiles = Profile::whereIn('id', $profile_ids)->get()->map(function ($table) {
            $table->total = $this->getsumforprofileidandrooftype($table->id, 0);
            // $table->columnz = $table->columnx + $table->columny;
            return $table;
        });

        return $profiles;
    }

    public function getWallProfilesAttribute()
    {
        //create collection
        $profile_ids = collect();

        //Gather all the roofing profiles used in the Project
        foreach ($this->estimate->sections()->where('sectiontype_id', 1)->get() as $section) {
            foreach ($section->claddings as $cladding) {
                // Add the profile ID to the list
                $profile_ids->push($cladding->profile->id);
            }
        }
        //remove duplicate ids
        $profile_ids = $profile_ids->unique();

        //gather the profiles
        $profiles = Profile::whereIn('id', $profile_ids)->get()->map(function ($profile) {
            $profile->total = $this->getsumforprofileidandrooftype($profile->id, 1);
            // $table->columnz = $table->columnx + $table->columny;
            return $profile;
        });

        return $profiles;
    }

    public function getsumforprofileidandrooftype($id, $roof_type)
    {
        $profile_cost_sum = 0;
        //Gather all the roofing profiles used in the Project
        foreach ($this->estimate->sections()->where('sectiontype_id', $roof_type)->get() as $section) {
            foreach ($section->claddings()->where('profile_id', $id)->get() as $cladding) {
                // Sum the cost for that cladding to the variable
                $profile_cost_sum = $profile_cost_sum + $cladding->cladding_cost;
            }
        }

        return $profile_cost_sum;
    }
}

Jul
29
3 months ago
Activity icon

Started a new Conversation How Do I Group The Similiar Lines And Total Them?

I want to display all the cladding that has been used on a particular job. However I need to group and total the similar profiles_ids.

                <table class="table table-striped">
                    <thead class="thead-light">
                        <tr>
                            <th scope="col">Qty</th>
                            <th scope="col">Description</th>
                            <th scope="col">Unit Price</th>
                            <th scope="col">Price</th>
                        </tr>
                    </thead>
                    <thead class="thead-light">
                        <tr>
                            <th scope="col"></th>
                            <th scope="col">Metal Roofing</th>
                            <th scope="col"></th>
                            <th scope="col"></th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach ($budget->estimate->sections as $section)
                        @foreach($section->claddings as $cladding)
                        <tr>
                            <th scope="row"></th>
                            <td>{{$cladding->profile->name}}</td>
                            <td>{{$cladding->guage->cost}}</td>
                            <td>{{$cladding->cladding_cost}}</td>
                        </tr>
                        @endforeach
                        @endforeach
                    </tbody>
                </table>

However my output is:

Qty	Description	Unit Price	Price
Metal Roofing		
VicWest 7/8" Corrugated	0.00	0.00
Agway 2-300	0.00	0.00
VicWest 7/8" Corrugated	0.00	0.00
VicWest 7/8" Corrugated	0.00	0.00
Agway 2-300	0.00	0.00
Agway 4-300	0.00	0.00

I would like to make it like:

VicWest 7/8" Corrugated	1.00	3.00
Agway 2-300	1.00	2.00
Agway 4-300	0.00	0.00
Activity icon

Replied to How Do I Gather All Records That Match A Certain Id?

Thanks... I haven't used that function in so long I almost forgot about it.

Activity icon

Started a new Conversation How Do I Gather All Records That Match A Certain Id?

I've gathered all the record id's I want to gather from the database in a collection($profile_ids) as so:

Illuminate\Support\Collection {#768 ▼
  #items: array:2 [▼
    0 => 32
    1 => 34
  ]
}

now I want to return all records that match those IDs. How to I gather them?

Profiles::where('id', $profile_ids)->get(); // ??????
Jul
20
3 months ago
Activity icon

Started a new Conversation Properly Format An Array To Make Function Work

When I use the crud sample from here it works perfectly fine: https://github.com/IntuitDeveloper/SampleApp-CRUD-PHP/blob/master/CRUD_Examples/Invoice/InvoiceCreate.php

THis works fine:

        $qbinvoice = Invoice::create([
            "Line" => [
                 [
                     "Amount" => 100.00,
                    "DetailType" => "SalesItemLineDetail",
                     "SalesItemLineDetail" => [
                         "ItemRef" => [
                              "value" => 1,
                             "name" => "Services"
                         ]
                     ]
                         ],
            ],
            "CustomerRef" => [
                "value" => $project->contractor->company->qb_companyid
            ],
            "BillEmail" => [
                "Address" => $project->contractor->company->email
            ],
            // "BillEmailCc" => [
            //     "Address" => "[email protected]"
            // ],
            // "BillEmailBcc" => [
            //     "Address" => "[email protected]"
            // ]
        ]);

however I'm trying to add multiple line items

this did not work:

        $qbinvoice = Invoice::create([
            "Line" => [
                // [
                //     "Amount" => 100.00,
                //     "DetailType" => "SalesItemLineDetail",
                //     "SalesItemLineDetail" => [
                //         "ItemRef" => [
                //             // "value" => 1,
                //             "name" => "Services"
                //         ]
                //     ]
                //         ],
                foreach ($bill->items as $item) {
                [
                    "Amount" => $item->total,
                    "DetailType" => "SalesItemLineDetail",
                    "SalesItemLineDetail" => [
                        "ItemRef" => [
                            // "value" => 1,
                            "name" => $item->costcode->desc
                        ]
                    ]
                ],
                }
            ],
            "CustomerRef" => [
                "value" => $project->contractor->company->qb_companyid
            ],
            "BillEmail" => [
                "Address" => $project->contractor->company->email
            ],
            // "BillEmailCc" => [
            //     "Address" => "[email protected]"
            // ],
            // "BillEmailBcc" => [
            //     "Address" => "[email protected]"
            // ]
        ]);

nor is this working:

        // Setup Line Items
        $lineitems = [];
        foreach ($bill->items as $item) {
            $lineitem = [
                "Amount" => $item->Amount,
                "DetailType" => "SalesItemLineDetail",
                "SalesItemLineDetail" => [
                    "ItemRef" => [
                        // "value" => 1,
                        "name" => $item->costcode->desc
                    ]
                ]
            ];
            array_push($lineitems, $lineitem);
        }

            $qbinvoice = Invoice::create([
                "Line" => $lineitems,
                "CustomerRef" => [
                    "value" => $project->contractor->company->qb_companyid
                ],
                "BillEmail" => [
                    "Address" => $project->contractor->company->email
                ],
                // "BillEmailCc" => [
                //     "Address" => "[email protected]"
                // ],
                // "BillEmailBcc" => [
                //     "Address" => "[email protected]"
                // ]
            ]);

            //save the record
            $resultingObj = app('QuickBooks')->getDataService()->Add($qbinvoice);
Jul
09
3 months ago
Activity icon

Started a new Conversation How To Structure Tables So Related Tables Id Numbers Stay Secuential?

I would like to make my migrations and models so that my Orders numbers per Users are sequential per User.

Each user has a Order 1,2,3....etc. If I were to make a standard OnetoMany relationships between User and Order; Order 1 might belongs to user 8 for example.

Jul
08
3 months ago
Activity icon

Started a new Conversation Trying To Use SortBy() Or SortByDesc() Gives Error And Last() As Well.

This:

            $lastbill = Bill::where('project_id', $project->id)->where('bill_type', 'p')->sortByDesc('created_at')->first();

produces error:

Call to undefined method Illuminate\Database\Eloquent\Builder::sortByDesc()

This:

$lastbill = Bill::where('project_id', $project->id)->where('bill_type', 'p')->last();

produces error:

Call to undefined method Illuminate\Database\Eloquent\Builder::last()

I know the record is there because when I do:

dd(Bill::where('project_id', $project->id)->where('bill_type', 'p')->count());

I get:

1
Jun
30
4 months ago
Activity icon

Replied to How To Query Though A Pivot Table?

I think it's because:

ContactRole::where('id', 5)->get();

could be many and

$project_managers = ContactRole::find(5);

is a singular record instance of that model.

Activity icon

Replied to How To Query Though A Pivot Table?

i think I figured it out.. all I did was change this:

$project_managers = ContactRole::where('id', 5)->get(); //Get only the project

to

$project_managers = ContactRole::find(5);

I can't tell what the difference really is.

Activity icon

Started a new Conversation How To Query Though A Pivot Table?

I use a pivot table for assigning roles to contacts:

...
class Contact extends Model
{
    protected $fillable = [
        'first_name',
        'last_name',
    ];
    
    public function roles()
    {
        return $this->belongsToMany('App\Models\contact\ContactRole');
    }
}

and

...
class ContactRole extends Model
{

    public function contacts()
    {
        return $this->belongsToMany('App\Models\contact\Contact');
    }
}

I'm trying to put them into as SELECT BOX as so:

                        <select id="contractor_id" class="component form-control" name="contractor_id" required>
                            <option>Pick a General Contractor....</option>
                            @foreach ($project_managers->contacts as $contact)
                            <option value="{{$contact->id}}">{{$contact->first_name}} - {{$contact->last_name}}</option>
                            @endforeach
                        </select>

however I get:

Property [contacts] does not exist on this collection instance. (View: /root/resources/views/project/create.blade.php)

I'm calling my view like this:

    public function create()
    {
        // $project_managers = Contact::wherePivot($roles(),5)->get();
        $project_managers = ContactRole::where('id', 5)->get(); //Get only the project manager roles
        return view('project.create', compact('project_managers'));
    }

As you can see I've already tried coming at it from another direction but could not make it work, so now I'm trying to come at through the roles.

Jun
29
4 months ago
Activity icon

Replied to Easiest Way To Get Errors Emailed To You?

Wow!.. thanks that's a life saver.

Activity icon

Started a new Conversation Easiest Way To Get Errors Emailed To You?

I wonder if there is some laravel plugin that would email the errors that would occur to me?

Jun
19
4 months ago
Activity icon

Replied to Problem Using Queues To Run A Job.

ErrorException Undefined property: App\Jobs\ProcessCladding::$section

Activity icon

Started a new Conversation Problem Using Queues To Run A Job.

config/queue.php is setup as sync:

...
    'default' => env('QUEUE_CONNECTION', 'sync'),
...

I dispatch the job when someone views the section like this from my controller:

    public function show($estimate_id, Section $section)
    {
        ProcessCladding::dispatch($section);
...

app/Jobs/ProcessCladding.php:

<?php

namespace App\Jobs;

use App\Section;
use App\Cladding;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

class ProcessCladding implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

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

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        // dd($section);
        // dd($this->section);
        foreach ($this->section->claddings as $cladding) {
            // if sequencing is turned on
            // if ($this->section->sequence == 1) {
            //     // get value from Results Routine
            //     return $this->SequencingResults;
            // } else {
            // If no sequencing is to be used
            //     $model = \App\Cladding::find($cladding->id);
            //     $model->num_of_sheets = ceil($this->width / $this->SheetWidth);
            //     $model->save();
            // }

            $model = Cladding::find($cladding->id);
            $model->num_of_sheets = 999;
            $model->save();
        }
    }
}

neither $section nor $this-section is being passed to the handle function. What am I missing?

Activity icon

Awarded Best Reply on Trimming Down An Expensive Query

Since each cladding area calculates itself in series, I'm playing with writing it value to a session variable so the next cladding only needs to add it's result to that session variable. So far I've been able to make it work..

    public function getSequencingResultsAttribute()
    {
        // Count previous records including itself
        $count = $this->section->claddings->where('id', '<=', $this->id)->count();
        // Extract widths for those records
        $SumOfWidths = $this->section->claddings->take($count)->sum('width');

        // Count previous records not including itself
        $count = $this->section->claddings->where('id', '<', $this->id)->count();
        // Extract Results for those records
        // $PreviousResults = $this->section->claddings->take($count)->sum('SequencingResults');
        // session(['PreviousResults' => floor($SumOfWidths / $this->SheetWidth - session('PreviousResults'))]);

        // If rounding Down is selected
        if ($this->rounding == 3) {
            return floor($SumOfWidths / $this->SheetWidth - session('PreviousResults'));
            session(['PreviousResults' => session('PreviousResults') + floor($SumOfWidths / $this->SheetWidth - session('PreviousResults'))]);
        }
        // else round up
        else {
            return  ceil($SumOfWidths / $this->SheetWidth - session('PreviousResults'));
            session(['PreviousResults' => session('PreviousResults') + ceil($SumOfWidths / $this->SheetWidth - session('PreviousResults'))]);
        }

    }