Dalma

Dalma

Member Since 2 Years Ago

Vancouver

Experience Points 21,430
Experience Level 5

3,570 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 106
Lessons
Completed
Best Reply Awards 11
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

16 Jul
6 days ago

Dalma left a reply on Laravel 5.7 | External Server Router Error

Are you using composer on this install, if so have you run composer update?

15 Jul
1 week ago

Dalma left a reply on Forge: Script For Adding Column To Production Database Table

If you have run composer require xxx/xxx in your development environment then this will update composer.json and composer.lock which when pushed to your repository via git will be pulled when the forge script runs.

git pull origin master <--- will download all of your changes including composer.json and composer.lock composer install --no-interaction --prefer-dist --optimize-autoloader <--- will download xxx/xxx package on your server

10 Jul
1 week ago

Dalma left a reply on Elegant Way To Fix Duplicated Many To Many Relationships

Okay I have figured this out so I thought I would share

$users = User::all();
foreach($users as $user){
  $roles = $user->roles->unique()->pluck('id');
  $user->roles()->sync([]);   // to clear old association
  $user->roles()->sync($roles);
}

Dalma started a new conversation Elegant Way To Fix Duplicated Many To Many Relationships

Hi everyone I'm looking for some elegant way to correct an issue I created. I have a Roles table which is a Many-to-many relationship with Users. Due to a bug in my code I now have Users that have the same Role attached 6 or 7 times.

I'm looking for an elegant way to code an update to fix the following example

User: Jim Jones
Role: Technician
          Technician
          Technician

User:Peter Smith
Role: Technician
          Coordinator
          Designer
          Designer
          Designer

I guess basically I'm wanting to return a list of unique attached roles and then perform a sync of these ids

Dalma left a reply on Failed To Parse Dotenv File Due To An Invalid Name.

Could your file be in the wrong location?

08 Jul
2 weeks ago

Dalma left a reply on Pulling ID Into Form Within Modal

I expect that you are getting the last id listed?

You are building your modal after your foreach list has completed which means the value you have in $game->id is the last one. You will need to use some javascript to read the id from your table.

      {!! Form::model($game, ['method' =>'PATCH', 'action'=> ['[email protected]', $game->id], 'files'=>true, 'enctype'=>'multipart/form-data']) !!}
      
03 Jul
2 weeks ago

Dalma left a reply on Random Schedule Cron

I would also vote that you stagger your backup's but assign each machine a specific time.

Dalma left a reply on Queue Processing - How It Works

Hi Ruborg, you start an OS command that is a queue worker. Details are here: https://laravel.com/docs/5.7/queues

19 Jun
1 month ago

Dalma left a reply on Deployment Log

Sorry I didn't think to search first. Thank you for your help.

Dalma started a new conversation Deployment Log

I see that the forge interface shows the latest deployment request directly on the UI. Is there an underlying log file with a series of deployments, if so does anyone know the file name and location?

Something happened yesterday on my site where existing code used for email notification events is suddenly not working today. This code has been running in production for two months and now today is throwing 'not property of object' errors. Using tinker I can pull up the object and it works correctly so I want to see if an install of one application program as triggered a laravel or symphony update when it was released through forge.

05 Jun
1 month ago

Dalma left a reply on Invalid Argument Supplied For Foreach()

Try changing your first() to get() and see if the error goes away.

Dalma left a reply on Scheduled Tasks In Laravel 5.7 App Triggered At Wrong Time

For my schedules I specify the timezone. Below is an example from the Laravel docs

$schedule->command('foo')
          ->weekdays()
          ->hourly()
          ->timezone('America/Chicago')
          ->between('8:00', '17:00');
27 May
1 month ago
10 May
2 months ago

Dalma left a reply on Is It Me Or Laravel Is Really Hard To Tame For Beginners?

This series is long but it builds step by step. I followed the entire series and then have viewed about another 100 posted on here and with each I was able to grow in my understanding.

Dalma left a reply on Is It Me Or Laravel Is Really Hard To Tame For Beginners?

I have been a software developer for a long time but had not worked with PHP at all and until recently didn't even know of Laravel. I found the following video series and by the time I was done I was in good shape.

This is on the DevMarketer youtube channel - Called build a blog with Laravel

https://www.youtube.com/watch?v=R8B4og-BeCk&list=PLwAKR305CRO-Q90J---jXVzbOd4CDRbVx&index=1

After following this series I was prepared for Jeff's more focused and advanced videos.

08 May
2 months ago

Dalma left a reply on JQuery Not Working In Blade Template

Are you loading the default bootstrap js as well somewhere, is it required by your library?

<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js">

Using the same Chrome inspection tool do you see any output in the Console section as it will show JS errors there?

07 May
2 months ago
06 May
2 months ago

Dalma left a reply on Cannot Read Html Element Data Attribute

I was successful with this format for reading data attributes

var $id = $(this).data('id');

28 Apr
2 months ago

Dalma left a reply on Commit To Forge Server Error

That is great news

27 Apr
2 months ago

Dalma left a reply on Error When Tryining To Delete Mysql Database;

Are you trying to do a drop from a ssh command line? I would suggest that you need to either be the database user via su dbusername or the root user.

Dalma left a reply on Commit To Forge Server Error

I think the issue you are facing is not with composer but with git on the forge server. I have run into this and had to execute a git command to stash my changes.

26 Apr
2 months ago

Dalma left a reply on Odd Image Upload Issue

If you have not already done so, check to see the URL being presented for images that work and those that don't work and compare paths and domain names. Hopefully something should be apparent and from that we can work to better assist you.

24 Apr
2 months ago

Dalma left a reply on I Could Use Some Assistance In Formatting A Query

I found my solution. I needed to wrap the inital or clauses in a closure

        $hightech = ['0' => 'Please Select'] +
            User::where(function ($query) use ($myofficeid) {
                $query->where('office_id','=', $myofficeid)
                      ->orwhereHas('offices', function ($query) use ($myofficeid){
                          $query->where('offices.id', '=', $myofficeid);
                      });
            })->where('status','=', 1)
            ->whereHas('roles', function ($query){
                $query->where('name','=', 'High Tech Coordinator');
            })->orderBy('name')->pluck('name','id')->toArray();

Dalma left a reply on Retrieve Data With Eloquent Relationships

try something like:

'departement_id' => Faculty::find($facultyId)

->whereHas( 'departements', function ($query) use ($request['departementName']) {
    $query->where('name', $request['departementName']);
})
->get()

Dalma started a new conversation I Could Use Some Assistance In Formatting A Query

I have a query that I'm struggling to get to bracket correctly, query appears at the end of this post

I have three relations:

User
User->offices()
User->roles()

The User has a default office id stored in the office_id field and a ManytoMany relationship accessed via the User->offices() relation and ManytoMany relationship accessed via the User->roles() relation.

to pseudocode

if $myofficeid > 0 ( find user where office_id = $myofficeid OR user->offices().id = $myofficeid) AND user->roles() has name = "High Tech Coordinator)

what I'm getting now is effectively

if $myofficeid > 0  find user where office_id = $myofficeid OR (user->offices().id = $myofficeid and user->roles() has name = "High Tech Coordinator)

I assumed that trying to place both of the office related queries in the ->when closure would bracket them together.

$hightech = ['0' => 'Please Select'] + User::where('status','=',1)
                                                    ->when($myofficeid > 0 , function($query) use($myofficeid){
                                                        $query->whereHas('offices', function($query) use ($myofficeid){
                                                            $query->where('offices.id', '=', $myofficeid);
                                                        })
                                                            ->orWhere('office_id','=',$myofficeid);
                                                    })
                                                    ->whereHas('roles', function ($query){
                                                        $query->where('name','=', 'High Tech Coordinator');
                                                    })->orderBy('name')->pluck('name','id')->toArray();
16 Apr
3 months ago

Dalma left a reply on Unexpected Else

No as that is a @if @elseif @else @endif or @if @elseif @endif

Dalma left a reply on Unexpected Else

I see 3 @if but 4 @endif statements??

Dalma left a reply on Blade @if @else

I think that you are missing ->total in your comparison statement.

10 Apr
3 months ago

Dalma left a reply on Remove Error Message After Open Second Time Of Modal

After you have a successful ajax call to populate your database you can in your javascript clear the data from the modal element(s).

09 Apr
3 months ago

Dalma left a reply on Eager Load

How do you have your eloquent relationships defined between your tables?

25 Mar
3 months ago

Dalma left a reply on Change CSS Dynamically

Using JQuery you can easily execute code that based on data embedded in your page can replace existing classes in elements.

If you had a div or field with a class of bg-light you could via JQuery remove bg-light and change it to bg-success as an example.

14 Mar
4 months ago

Dalma left a reply on PHP Confusion

I don't think that laravel loaded Php on your computer, it must have been installed previously. Normally on a windows machine a package like WAMP is installed which provides Php and MySql. I would guess that you already had Php on your machine.

05 Mar
4 months ago

Dalma left a reply on Reusing Codeblocks In Blade

Hi @sergiu17 that worked perfectly.

Dalma left a reply on Reusing Codeblocks In Blade

Would the substituted code then end up as

$$parent

Dalma started a new conversation Reusing Codeblocks In Blade

I have a large blade view file where a section of code is repeated except for a variable name that is table specific.

I have a view with a parent, child, grandchild relationship and within each I have 30 line block of code that repeats except that in each it has a {{$parent->id}} or {{$child->id}} or {{$grandchild->id}} embedded.

I'm trying to pull all 30 lines of code into another blade template and then pass in a variable being the $table name.

Something like

@include('admin.project.scheduleblock', ['table' => '$parent'])

@include('admin.project.scheduleblock', [table => '$child'])

If this does in fact work I can't figure out the appropriate syntax.

Dalma left a reply on Weird Namespacing Issue?

Hi @cronix I don't have any model specific aliases in the /config/app.php. I will chock this Tinker issue up to something unusual with the name of my class. As always thank you for your help.

Dalma left a reply on Weird Namespacing Issue?

Hi @cronix in my regular code I do have the use statement in place. When using Tinker I never need to specify the App\ name except for this model.

[!] Aliasing 'Stage' to 'App\Stage' for this Tinker session.
=> App\Stage {#4334
     id: 12,
     created_at: "2018-10-04 09:00:29",
     updated_at: "2018-10-04 09:00:29",
     name: "Not Started",
   }
>>>

All of the other models have the Aliasing message, this must mean that the class name of Schedule must confuse tinker.

Dalma started a new conversation Weird Namespacing Issue?

I have a model named Schedule that has an unexpected namespacing issue, it behaves differently than my other models. Laravel 5.7

I will contrast two models

Schedule (not working as expected - this is also my first polymorphic model)

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Spatie\Activitylog\Traits\LogsActivity;


class Schedule extends Model
{
    use LogsActivity;

    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'schedules';

    /**
    * The database primary key value.
    *
    * @var string
    */
    protected $primaryKey = 'id';

    /**
     * Attributes that should be mass-assignable.
     *
     * @var array
     */
    protected $fillable = ['start_dt', 'end_dt', 'note', 'schedulable_id', 'schedulable_type'];

    public function schedulable()
    {
        return $this->morphTo();
    }
}

Task model that works as expected

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Spatie\Activitylog\Traits\LogsActivity;
use App\Events\TaskUpdated;


class Task extends Model
{
    use LogsActivity;

    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'tasks';

    /**
    * The database primary key value.
    *
    * @var string
    */
    protected $primaryKey = 'id';

    /**
     * Attributes that should be mass-assignable.
     *
     * @var array
     */
    protected $fillable = ['phase_id', 'name', 'start_date', 'end_date', 'required', 'stage_id', 'tech_id', 'notes', 'technotes', 'status_id', 'dependant_upon', 'weight'];

    protected static $logFillable = true;

    public function phase()
    {
        return $this->belongsTo('App\Phase');
    }
    public function stage()
    {
        return $this->belongsTo('App\Stage');
    }
    public function tech()
    {
        return $this->belongsTo('App\User');
    }
    public function status()
    {
        return $this->belongsTo('App\Status');
    }
    public function user()
    {
        return $this->belongsTo('App\User');
    }

    public function schedules()
    {
        return $this->morphMany('App\Schedule','schedulable');
    }

    protected $dispatchesEvents = [
      'updated' =>   TaskUpdated::class,
    ];
}

from the following tinker commands

Task::first()

This returns the first model as expected

Schedule::first()

This fails with the message PHP Fatal error: Class 'Schedule' not found

App\Schedule::first()

This works

Both of the models are in the normal laravel file structure in the app directory.

Is Schedule perhaps a reserved word or have I overlooked the obvious?

28 Feb
4 months ago

Dalma left a reply on Laravel Is Very Slow In Localhost

So your problem does not seem to be network related.

Dalma left a reply on Laravel Is Very Slow In Localhost

Is your computer connected to domain controller or any other device that may act as a DNS controller?

From a command prompt try and run a traceroute

tracert localhost

Do you have multiple hops to your host?

Dalma left a reply on Laravel Is Very Slow In Localhost

My first guess would be something unusual in your hosts file.

Can you share the content of your C:/Windows/System32/drivers/etc/hosts file?

Do you have something like?

127.0.0.1 localhost
::1 localhost

Do you have other content in this file?

Dalma left a reply on UI And Data Structure For Array Of Dates

Of course this makes sense. Thank you.

27 Feb
4 months ago

Dalma left a reply on Database Error

Was this a previously working database connection or is this a new site?

Dalma started a new conversation UI And Data Structure For Array Of Dates

I'm working on a project management tool were there will be a series of tasks. Each task may have either

    1. a single date
    1. a single date range with a start date and end date
    1. multiple date ranges each with a start and end date

How have you presented this in the UI and then how did you store the data?

Dalma left a reply on HELP!! 500: Server Error (Laravel) With Zero Information On Why Its Not Working...

Have you configured Wamp's Apache server to host your site and respond on port 8000 or are you attempting to use the small server included with laravel which is started via

php artisan serve

As the php server responds on port 8000 I suspect that this is the server that you are attempting to hit and it may not be running unless you issued the command above.

26 Feb
4 months ago

Dalma left a reply on Problem When Deploying Via Laravel Forge

Is this a new deployment or are you releasing and update to your existing site?

Dalma left a reply on Get Image Preview From PDF File

There are always other options but this is a clean and easy to implement package.

Dalma left a reply on Migration Do Not Work In Laravel 5.8

I have created some new projects and overlooked the database configuration in the .env file?

Dalma left a reply on Problem With Adding Image To Product

Can you also post your Blade Form that is submitting this request?

I'm not sure if this is an issue but you may have issues with permissions on your images/product_images path?