fbc

fbc

Member Since 3 Years Ago

Experience Points
7,830
Total
Experience

2,170 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
7,830 XP
Jun
30
4 days 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
5 days 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
2 weeks 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'))]);
        }

    }
Jun
16
2 weeks ago
Activity icon

Started a new Conversation Best Practices When Nesting Controllers?

Should you go with:

Route::resource('a', 'aController');
Route::resource('a.b', 'bController');
Route::resource('a.b.c', 'cController');
Route::resource('a.b.c.d', 'dController');

or

Route::resource('a', 'aController');
Route::resource('a.b', 'bController');
Route::resource('b.c', 'cController');
Route::resource('c.d', 'dController');

??? My gut tells me a.b.c.d but I'm unsure.

Jun
11
3 weeks ago
Activity icon

Replied to Trimming Down An Expensive Query

I figured it out:

    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');

        if ($this->rounding == 3) {
            $x = floor($SumOfWidths / $this->SheetWidth - Session::get('PreviousResults'));
            Session::put('PreviousResults', Session::get('PreviousResults') + floor($SumOfWidths / $this->SheetWidth - Session::get('PreviousResults')));
            return $x;
        }
        // else round up
        else {
            $x = ceil($SumOfWidths / $this->SheetWidth - Session::get('PreviousResults'));
            Session::put('PreviousResults', Session::get('PreviousResults') + ceil($SumOfWidths / $this->SheetWidth - Session::get('PreviousResults')));
            return $x;
        }
    }

Activity icon

Replied to 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'))]);
        }

    }
Activity icon

Replied to Trimming Down An Expensive Query

Many claddings belong to a section. In order to calculate this correctly , it needs to sum the 'SequencingResults' of the previous cladding areas.

Activity icon

Started a new Conversation Trimming Down An Expensive Query

I have an query that takes almost 3 minutes to give results. It pins one of the CPU cores at 100% the whole time. I'm trying to figure out a way to get the same result without the expensive query. The results are correct, so I have no complaints about that.

App\Cladding.php(Model)

<?php

namespace App;

use App\BusinessParameters;
use Illuminate\Database\Eloquent\Model;

class Cladding extends Model
{
    protected $fillable = [
        'section_id',
        'profile_id',
        'width',
        'length',
        'guage_id',
        'color_id',
        'fastenertype_id',
        'screw_spacing',
        'orientation',
        'rounding',
        'vbar_coverage_per_day',
        'vbar_num_of_men',
        'insu_coverage_per_day',
        'insu_num_of_men',
        'subg_coverage_per_day',
        'subg_num_of_men',
        'mclosure',
        'fclosure',
        'custom_width',
    ];
...
    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');


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

the expensive part of this query is:

        $PreviousResults = $this->section->claddings->take($count)->sum('SequencingResults');

If remove this line the calculation completes very quickly but of course it's incorrect.

Can anyone see the best way to trim this query down?

May
19
1 month ago
Activity icon

Started a new Conversation Using Where Through A Relationship Possible In A Blade?

Could something like this be made to work?

            <table class="table table-striped">
                <thead class="thead-light">
                    <tr>

                        <th scope="col">Name</th>
                        <th scope="col">Survey Taken?</th>
                        <th scope="col">Action</th>
                    </tr>
                </thead>
                <tbody>

                    @foreach ($commissionedsurvey->teamid->user as $user)
                    <tr>

                        <td>
                            {{$user->user->name}}
                        </td>
                        <td>
                            @if ($user->survey->where('commissioned_survey_id',$commissionedsurvey->id)->count() == 0)
                            No
                            @endif

                            @if ($user->survey->where('commissioned_survey_id',$commissionedsurvey->id)->count() > 0)
                            Yes
                            @endif
                        </td>
                        <td>
<!-- Insert buttons here -->
                        </td>
                    </tr>
                </tbody>
                @endforeach
Apr
30
2 months ago
Activity icon

Replied to How Do I Copy The Data In A Collection Without Assuming The Model?

Thanks that ->getAttributes() really helped!

Activity icon

Started a new Conversation How Do I Copy The Data In A Collection Without Assuming The Model?

I want to copy the values from one collection to a new collection however, it's assuming the model of the WALLTYPES and trying to save a new walltype instead of cladding.

        $walltype = WallType::where('id', $request->walltype_id)->first();

        $cladding = new Cladding;
        $cladding = $walltype;
        $cladding->length = (float) $request->length;
        $cladding->width = (float) $request->width;

        $cladding->save();

Cladding:

App\Cladding {#496 ▼
  #fillable: array:19 [▼
    0 => "section_id"
    1 => "profile_id"
    2 => "width"
    3 => "length"
    4 => "guage_id"
    5 => "color_id"
    6 => "fastenertype_id"
    7 => "screw_spacing"
    8 => "orientation"
    9 => "rounding"
    10 => "vbar_coverage_per_day"
    11 => "vbar_num_of_men"
    12 => "insu_coverage_per_day"
    13 => "insu_num_of_men"
    14 => "subg_coverage_per_day"
    15 => "subg_num_of_men"
    16 => "mclosure"
    17 => "fclosure"
    18 => "custom_width"
  ]
  #connection: null
  #table: null
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  #perPage: 15
  +exists: false
  +wasRecentlyCreated: false
  #attributes: []
  #original: []
  #changes: []
  #casts: []
  #dates: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: []
  #touches: []
  +timestamps: true
  #hidden: []
  #visible: []
  #guarded: array:1 [▶]
}

Walltype:

App\WallType {#506 ▼
  #fillable: array:19 [▶]
  #connection: "mysql"
  #table: "wall_types"
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  #perPage: 15
  +exists: true
  +wasRecentlyCreated: false
  #attributes: array:22 [▼
    "id" => 1
    "job_id" => 1
    "name" => "wt1"
    "profile_id" => 32
    "guage_id" => 17
    "color_id" => 0
    "custom_color" => null
    "custom_width" => null
    "fastenertype_id" => 2
    "screw_spacing" => "1.33"
    "mclosure" => 0
    "fclosure" => 0
    "orientation" => 2
    "rounding" => 2
    "vbar_coverage_per_day" => 1
    "vbar_num_of_men" => 1
    "insu_coverage_per_day" => 1
    "insu_num_of_men" => 1
    "subg_coverage_per_day" => 1
    "subg_num_of_men" => 1
    "created_at" => "2020-04-30 08:35:30"
    "updated_at" => "2020-04-30 11:02:30"
  ]
  #original: array:22 [▶]
  #changes: []
  #casts: []
  #dates: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: []
  #touches: []
  +timestamps: true
  #hidden: []
  #visible: []
  #guarded: array:1 [▶]
}

Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'length' in 'field list' (SQL: update wall_types set length = 12, width = 12, wall_types.updated_at = 2020-04-30 11:34:53 where id = 1)

I don't have a length column in Walltypes, so I'm assuming that is where it's trying to write to.

Activity icon

Started a new Conversation Please Delete

please delete

Apr
28
2 months ago
Activity icon

Started a new Conversation How Do You Regenerate The Section Above The Functions That Describe It?

I remember running into a composer package that you would install that would regenerate(via artisan) those comment sections and compile a file in the root of the laravel folder that would assist the editor in predicting the namespace of object you type.

Activity icon

Replied to Artisan Nested Resource Controllers Creation

yes, correct, now try to do it for parents 3 layers deep. like Country State County

It seems like it only supports 1 layer deep.

Activity icon

Replied to Artisan Nested Resource Controllers Creation

-p(for parent) is not an option for Model Class.

Activity icon

Replied to Artisan Nested Resource Controllers Creation

So what would have been the argument for the last one? -p=country.state.county ??

php artisan make:controller -m=City -r -p=country.state.county City
Activity icon

Started a new Conversation Artisan Nested Resource Controllers Creation

Does Artisan support the creation of nested resource controllers?

I like the 'php artisan make:model -mcr' command because it's a time saver.

However it would be great if you could reference a parent resource controller to make it easier to create nested resource controller. Going back and placing the parameters into each function section in the controllers is uncomfortable.

Any ideas?

Route::resource('country', 'CountryController');
Route::resource('country.state', 'StateController');
Route::resource('country.state.county', 'CountyController');
Route::resource('country.state.county.city', 'CityController');
Apr
22
2 months ago
Activity icon

Replied to Pluck Through Relationships Possible? Model Solution Possible?

This solved my problem in the first section:

        // trying to extract measurement_unit though the relationship between Job and section.
        $section_data = Section::where('id',$request->section_id)->first();
        $measurement_unit = $section_data->job->measurement_unit;
       // dd($measurement_unit);

However I would relaly like to learn how to do it in the model on the fly.

Activity icon

Awarded Best Reply on Non-static Method Illuminate\Support\Collection::where() Should Not Be Called Statically

I just approached it in a different manner and it works now.

        // Get Vertial Cladding ids and add them to an array
        $cladding_ids = [];
        $vertical_cladding_cost_sum = 0;
        foreach ($job->sections as $section){
            // get vertical cladding
            foreach ($section->claddings as $cladding){
                // If Orientation is Vertical
                if ($cladding->orientation == 2){
                    // Push the ID to the Array
                    array_push($cladding_ids,$cladding->profile->id);
                    // Sum the cost for that cladding to the variable
                    $vertical_cladding_cost_sum = $vertical_cladding_cost_sum + $cladding->MaterialCost;
                }
            }
        }
Activity icon

Started a new Conversation Pluck Through Relationships Possible? Model Solution Possible?

I'm trying to pluck the measurement unit for job through the relationship of the section.

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        // trying to extract measurement_unit though the relationship between Job and section.
        $measurement_unit = Section::where('id',$request->section_id)->first()->pluck($this->job->measurement_unit);
        //dd($measurement_unit);

        // If measurement unit is Metric convert all values to feet before it's saved
        if ($measurement_unit == 1) {
            $request->merge(['width' => $request->width / 0.3048]);
            $request->merge(['length' => $request->length / 0.3048]);
        }

        $cladding = Cladding::create($request->all());
        return redirect()->route('cladding.edit', $cladding->id);
    }

eventually I want to learn to do this via the Model on the Fly.

I imagine it would go something like this in the Model:

public function save(){
// If measurement unit is Metric convert all values to feet before it's saved
if ($this->section->job->measurement_unit == 1){
            $this->width = $this->width / 0.3048;
            $this->length = $this->length / 0.3048;
}

public function read(){
// If measurement unit is Metric convert all values to metric before it's displayed
if ($this->section->job->measurement_unit == 1){
            $this->width = $this->width * 0.3048;
            $this->length = $this->length * 0.3048;
}

}
Apr
17
2 months ago
Activity icon

Replied to Non-static Method Illuminate\Support\Collection::where() Should Not Be Called Statically

I just approached it in a different manner and it works now.

        // Get Vertial Cladding ids and add them to an array
        $cladding_ids = [];
        $vertical_cladding_cost_sum = 0;
        foreach ($job->sections as $section){
            // get vertical cladding
            foreach ($section->claddings as $cladding){
                // If Orientation is Vertical
                if ($cladding->orientation == 2){
                    // Push the ID to the Array
                    array_push($cladding_ids,$cladding->profile->id);
                    // Sum the cost for that cladding to the variable
                    $vertical_cladding_cost_sum = $vertical_cladding_cost_sum + $cladding->MaterialCost;
                }
            }
        }
Activity icon

Started a new Conversation Non-static Method Illuminate\Support\Collection::where() Should Not Be Called Statically

I can't understand why this is wrong.

    public function printview($job_id)
    {
        $job = Job::where('id',$job_id)->first();
        $cladding_ids = [];
        foreach ($job->sections as $section){
            // get vertical cladding
            foreach ($section->claddings::where('orientation',2) as $cladding){
                $cladding_ids = Arr::add($cladding_ids,'id',$cladding->profile->id);
            }
        }
        return view('estimate.printview', compact(
            'job'
        ));
    }
Apr
02
3 months ago
Activity icon

Awarded Best Reply on Script For Updating From Git And Renewing Your Environment

Disregard I learned how to inject static data in my migrations and stop using seeding to inject production data into tables.

Activity icon

Replied to Script For Updating From Git And Renewing Your Environment

Disregard I learned how to inject static data in my migrations and stop using seeding to inject production data into tables.

Activity icon

Started a new Conversation Script For Updating From Git And Renewing Your Environment

Since the COVID state of emergency has hit, my office is rotating it's staff to comply with the gathering of 6 person limit. (i.e no more than 6 people in the office at a time)

Which means sometimes I'm working from home and sometimes I'm in the office.

I would like to know if there is a pre-built script out there somewhere that refreshes my project from the git repository as I move from home to office every other day?

I assume there has to be an animal of the sort that you can run that will:

  • pull the latest git version
  • apply migrations
  • dump the autoload
  • apply new seeds
  • restart the "php artisan serve"

There have to be others out there that are going through the same thing.

Update: I found a script that almost does everything I want. How do I make it run any new seeders after the migrate?

# Change to the project directory
cd /home/forge/domain.com

# Turn on maintenance mode
php artisan down

# Pull the latest changes from the git repository
# git reset --hard
# git clean -df
git pull origin master

# Install/update composer dependecies
composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev

# Run database migrations
php artisan migrate --force

# Clear caches
php artisan cache:clear

# Clear expired password reset tokens
php artisan auth:clear-resets

# Clear and cache routes
php artisan route:clear
php artisan route:cache

# Clear and cache config
php artisan config:clear
php artisan config:cache

# Install node modules
# npm install

# Build assets using Laravel Mix
# npm run production

# Turn off maintenance mode
php artisan up
Mar
31
3 months ago
Activity icon

Started a new Conversation How Do Populate A Dropdown Select With Multiple Field Elements?

I want first and last name to appear in the dropdown list. I'm using the laravelcollective/html package. I currently use this:

  {{Form::select('id',$users, null, ['placeholder' => 'Pick a contractor...'])
public function create()
{
    $users = Users::all(['id', 'first_name','last_name']);

    return view('account.create', compact('id', 'users'));
}

In essence I want to end up with something like this!

<select>
@foreach ($users as user)
<option value="{{$user->id}}">{{$user->first_name}} {{$user->last_name}}</option>
@endforeach
</select>
Mar
20
3 months ago
Activity icon

Replied to Is There A Helper That Will Return A Value As A Whole Number If No Decimal Exists?

YEs!! That was exactly what I was looking for!!!

Activity icon

Replied to Is There A Helper That Will Return A Value As A Whole Number If No Decimal Exists?

I guess I can write if statements. I was just hoping there was a helper that did it for you.

Activity icon

Started a new Conversation Is There A Helper That Will Return A Value As A Whole Number If No Decimal Exists?

Is there a helper that will return a value as a whole number if no decimal exists?

I don't want to keep displaying values in my blade files with decimals if none exists.

Activity icon

Replied to PHP Fatal Error: Interface 'Symfony\Contracts\Translation\LocaleAwareInterface' Not Found In

it doesn't work for some reason.

What did work was deleting the Vendors sub folders and running composer install again.

Activity icon

Replied to Trouble Updating Checkbox Element With Boolean Fields.

@joukebouke @camilovietnam @snapey @jlrdw Thank you guys for all the replies and help.

I finally decided to solve the problem with dropdown boxes instead.

                    <div class="col-md-2">
                        {!!Form::label('tcaulking', 'Tape Caulking')!!}<br />
                        {!!Form::select('tcaulking', [0 => 'No', 1 => 'One', 2 => 'Two'])!!}
                    </div>

                    <div class="col-md-2">
                        {!!Form::label('acaulking', 'Acoustic Caulking')!!}<br />
                        {!!Form::select('acaulking', [0 => 'No', 1 => 'One', 2 => 'Two', 3 => 'Three'])!!}
                    </div>

Thanks again!

Activity icon

Started a new Conversation PHP Fatal Error: Interface 'Symfony\Contracts\Translation\LocaleAwareInterface' Not Found In

I moved my project from a Linux computer to a MACOS computer and getting all sorts of errors.

I get these strange errors I can't figure out. I do also remember there being a warning that symlinks would not be copied onto my exfat formatted portable drive that I used to transport the code to my MAC.

So the folder I copied to my mac came from that exfat formatted drive.

I was originally getting this:

$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating optimized autoload files
Warning: Ambiguous class resolution, "Symfony\Component\Mime\Header\IdentificationHeader" was found in both "/Users/fbc/LaravelProjects/estimator/vendor/symfony/mime/Encoder/Base64MimeHeaderEncoder.php" and "/Users/fbc/LaravelProjects/estimator/vendor/symfony/mime/Header/IdentificationHeader.php", the first will be used.
Warning: Ambiguous class resolution, "Symfony\Component\HttpKernel\DependencyInjection\AddAnnotatedClassesToCachePass" was found in both "/Users/fbc/LaravelProjects/estimator/vendor/symfony/http-kernel/Controller/TraceableArgumentResolver.php" and "/Users/fbc/LaravelProjects/estimator/vendor/symfony/http-kernel/DependencyInjection/AddAnnotatedClassesToCachePass.php", the first will be used.
Warning: Ambiguous class resolution, "Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension" was found in both "/Users/fbc/LaravelProjects/estimator/vendor/symfony/http-kernel/Controller/TraceableControllerResolver.php" and "/Users/fbc/LaravelProjects/estimator/vendor/symfony/http-kernel/DependencyInjection/ConfigurableExtension.php", the first will be used.
Warning: Ambiguous class resolution, "Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher" was found in both "/Users/fbc/LaravelProjects/estimator/vendor/symfony/http-kernel/Controller/ControllerResolverInterface.php" and "/Users/fbc/LaravelProjects/estimator/vendor/symfony/http-kernel/Debug/TraceableEventDispatcher.php", the first will be used.
Warning: Ambiguous class resolution, "Symfony\Component\HttpKernel\Debug\FileLinkFormatter" was found in both "/Users/fbc/LaravelProjects/estimator/vendor/symfony/http-kernel/Controller/ControllerResolver.php" and "/Users/fbc/LaravelProjects/estimator/vendor/symfony/http-kernel/Debug/FileLinkFormatter.php", the first will be used.
Warning: Ambiguous class resolution, "Symfony\Component\CssSelector\XPath\Extension\PseudoClassExtension" was found in both "/Users/fbc/LaravelProjects/estimator/vendor/symfony/css-selector/XPath/Extension/PseudoClassExtension.php" and "/Users/fbc/LaravelProjects/estimator/vendor/symfony/css-selector/Parser/Parser.php", the first will be used.
Warning: Ambiguous class resolution, "Symfony\Component\Console\Exception\CommandNotFoundException" was found in both "/Users/fbc/LaravelProjects/estimator/vendor/symfony/console/Command/ListCommand.php" and "/Users/fbc/LaravelProjects/estimator/vendor/symfony/console/Exception/CommandNotFoundException.php", the first will be used.
Warning: Ambiguous class resolution, "Illuminate\Routing\RouteGroup" was found in both "/Users/fbc/LaravelProjects/estimator/vendor/laravel/framework/src/Illuminate/Routing/RouteGroup.php" and "/Users/fbc/LaravelProjects/estimator/vendor/laravel/framework/src/Illuminate/Routing/RedirectController.php", the first will be used.
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Copyright (c) 2004-2020 Fabien Potencier

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
36 U+0036 six
!37 U+0037 seven
!38 U+0038 eight
!39 U+0039 nine
!3A U+003A colon
!3B U+003B semicolon
!3C U+003C less
!3D U+003D equal
!3E U+003E greater
!3F U+003F question
!40 U+0040 at
!41 U+0041 A
!42 U+0042 B
!43 U+0043 C
!44 U+0044 D
!45 U+0045 E
!46 U+0046 F
In Finder.php line 101:
                                                                              
  Class 'Symfony\Component\Finder\Iterator\FileTypeFilterIterator' not found  
                                                                              

Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

but then I did a COMPOSER UPDATE and it all went away.

Now I only get this error:

$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating optimized autoload files
Deprecation Notice: Class Sabberworm\CSS\Value\Value located in ./vendor/sabberworm/php-css-parser/lib/Sabberworm/CSS/Parsing/UnexpectedTokenException.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
PHP Fatal error:  Interface 'Symfony\Contracts\Translation\LocaleAwareInterface' not found in /Users/fbc/LaravelProjects/estimator/vendor/symfony/translation/TranslatorInterface.php on line 24

   Symfony\Component\Debug\Exception\FatalErrorException  : Interface 'Symfony\Contracts\Translation\LocaleAwareInterface' not found

  at /Users/fbc/LaravelProjects/estimator/vendor/symfony/translation/TranslatorInterface.php:24
    20|  * @author Fabien Potencier <[email protected]>
    21|  *
    22|  * @deprecated since Symfony 4.2, use Symfony\Contracts\Translation\TranslatorInterface instead
    23|  */
  > 24| interface TranslatorInterface extends LocaleAwareInterface
    25| {
    26|     /**
    27|      * Translates the given message.
    28|      *


   Whoops\Exception\ErrorException  : Interface 'Symfony\Contracts\Translation\LocaleAwareInterface' not found

  at /Users/fbc/LaravelProjects/estimator/vendor/symfony/translation/TranslatorInterface.php:24
    20|  * @author Fabien Potencier <[email protected]>
    21|  *
    22|  * @deprecated since Symfony 4.2, use Symfony\Contracts\Translation\TranslatorInterface instead
    23|  */
  > 24| interface TranslatorInterface extends LocaleAwareInterface
    25| {
    26|     /**
    27|      * Translates the given message.
    28|      *

  Exception trace:

  1   Whoops\Run::handleError("Interface 'Symfony\Contracts\Translation\LocaleAwareInterface' not found", "/Users/fbc/LaravelProjects/estimator/vendor/symfony/translation/TranslatorInterface.php")
      /Users/fbc/LaravelProjects/estimator/vendor/filp/whoops/src/Whoops/Run.php:408

  2   Whoops\Run::handleShutdown()
      [internal]:0
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255

Any Ideas?

Mar
19
3 months ago
Activity icon

Started a new Conversation Trouble Updating Checkbox Element With Boolean Fields.

In my edit blade i have:

                {!! Form::open(['route' => ['detail.update',$detail->id],'method' => 'put']) !!}
                {!! Form::token() !!}
                    @if ($detail->tcaulking == 0)
                    {{Form::checkbox('tcaulking', $detail->tcaulking)}}
                    @endif
                    @if ($detail->tcaulking == 1)
                    {{Form::checkbox('tcaulking', $detail->tcaulking,true)}}
                    @endif
                    {{Form::label('tcaulking', 'Tape Caulking')}}
                    <button type="submit" class="btn btn-success">Save</button>
                    {!! Form::close() !!}

when I hit save the value in the DB never changes to '0'. All other fields like 'name' work and update just fine.

Mar
18
3 months ago
Activity icon

Replied to Is It Possible To Create A Virtual Field In My Model?

How would I create it for $section->length_of_sheet ?

public function getLength_of_sheetAttribute() doesn't seem to work.

Activity icon

Started a new Conversation Is It Possible To Create A Virtual Field In My Model?

I was thinking of wanting to do something like this:

class Section extends Model
{
    protected $fillable = [
        'name',
        'job_id',
        'sectiontype_id',
        'profile_id',
        'width',
        'length',
        'sheet_length',
        'sheet_overlap',
        'fastenertype_id',
        'guage',
        'color',
        'temp_spacing',
        'screw_spacing',
        'slope_factor',
    ];

    public function area() {
	//calculate total SQ FT on the fly
	$area = $this->width * $this->length;
        return $area;
    }
{

but I get:

App\Section::area must return a relationship instance.

when I try to use:

{{$section->area}}

in a blade file.

Mar
17
3 months ago
Activity icon

Started a new Conversation Is It Possible To Add New Columns With Data To An Existing Collection?

In order to keep all of my logic in my controller and out of my view file.

Could do something l like this?

$examples = Table::all();

//Total Column columnx and columny to make a new column called columnz
foreach ($examples as $example){
arraypush($example, ['columnz' => $columnx+$columny])
}

so that you can use it in the view file like:

@foreach ($examples as $example)
Column X:{{$example->columnx}}
Column Y:{{$example->columny}}
Column Z:{{$example->columnz}}
@endforeach

What is the easiest way to accomplish something like that? Or should I just push everything to a new array?

Feb
28
4 months ago
Activity icon

Started a new Conversation How To Dropdown With Fill-in Your Own.. Possible Even?

How would you offer a dropdown with common options with a fill-in-your-own?

I ran into a problem where I would like to offer a dropdown box that also allowed you to fill-in your own. Is it even possible or what would be a good idea to do in this case?

Feb
21
4 months ago
Activity icon

Replied to Easiest Way To Store And Retrieve Array - DB Table Type?

Are there guides on either methods with examples?

Activity icon

Replied to Easiest Way To Store And Retrieve Array - DB Table Type?

How would you go about creating the table for it? In the first scenario? @sinnbeck

Activity icon

Started a new Conversation Easiest Way To Store And Retrieve Array - DB Table Type?

I have a form with a multiple select dropdown. Like so:

                                    {{select()->name('subframing_id')->label('SubFraming')->placeholder('')->options(collect([
                                        ['id' => 1, 'title' => 'Woodstrapping'],
                                        ['id' => 2, 'title' => 'Z-Subgirts(Horizontal)'],
                                        ['id' => 3, 'title' => 'Z-Subgirts(Vertical)'],
                                        ['id' => 4, 'title' => 'HatBar(Horizontal)'],
                                        ['id' => 5, 'title' => 'HatBar(Vertical)'],
                                        ]), 'id', 'title')->multiple()
                                        {{-- ->selected('id', 1) --}}
                                    }}

the controller command that stores it reads:

        Elevation::create($elevation->all());

what should the DB field type be to accept that data? You will understandably get an "array to string conversion" error if you try to go with an integer field.

       dd($elevation->subframing_id);

gives

array:2 [▼
  0 => "2"
  1 => "3"
]

In the old days we'd have to make a table with a foreign key constraint and do a FOREACH loop to store the data with the id that ties it to the parent record so we could query it in the future.

There must be an easier way now a days, right?