Dalma

Dalma

Member Since 2 Years Ago

Vancouver

Experience Points 23,370
Experience Level 5

1,630 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 117
Lessons
Completed
Best Reply Awards 12
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 Sep
12 hours ago

Dalma left a reply on CSS Not Working !

Using the same tool if you you select any element and explore the attached sytles what do you see? If you are not seeing an error I would then think that your css styles are being overriden?

Also using the developer tool you should be able to explore your html document and in the header where you see your stylesheet being applied it should be a link where you can click on it and see that you in fact do have content in your attached stylesheet.

The most common issues are:

  1. Your style sheet does not load at all which should trigger an error visible in the console.
  2. Your styles are being overridden by another stylesheet.
  3. Your sass build is in fact creating an empty or malformed file.

Dalma left a reply on CSS Not Working !

If you use Google Chrome and visit > More tools > Developer tools do you see any errors in the console tab?

13 Sep
3 days ago

Dalma left a reply on Query Efficiency

With Eloquent queries there is a concept called Eager Loading where in the Eloquent query you specify which other records to load using a 'with' statement. I recommend that you read up on this.

https://laravel.com/docs/5.8/eloquent-relationships#eager-loading

12 Sep
4 days ago

Dalma left a reply on Forge Down?

I understand that this is being addressed now: https://twitter.com/themsaid/status/1172166429648543744

Dalma left a reply on FORGE IS DOWN

I understand that this is being addressed now: https://twitter.com/themsaid/status/1172166429648543744

11 Sep
5 days ago

Dalma left a reply on User Specific Alerts With Many Filters

Lets call the data that people are uploading Opportunites.

I would look to create your system like this.

Let people upload Opportunities and as they are uploaded you set a flag on their record saying not processed.

On a timer, lets say once per hour you kick off a job that walks through all of your users and for each of them you run a routine that compares their filters against the new Opportunities and sends notifications as needed. Once done all of the Opportunities you just processed are flagged as complete.

As new Users join your system you set a flag on their saying not processed.

On a timer, lets say once per day you kick off a job that walks through the new users and for each of them you run a routine that compares their filters against ALL Opportunities and sends them notifications as needed.

For the 'flag' on Opportunities and Users I would use an numeric integer batch number that you increment just before kicking off your long running jobs such that you don't have a new Opportunity or User created while your job is running that is accidentally skipped.

10 Sep
6 days ago

Dalma left a reply on Laravel Datatables Search Error

Is this a production machine or are you testing this via 'php artisan serve' server?

09 Sep
1 week ago

Dalma left a reply on Updating Database On JQuery.ajax Call

Something like:

foreach ($pages as $page) {
  foreach($page->children as $children) {
 
    // your update logic here
    // start with a dd($page,$children) to dump the values returned to your controller

   }
}

Dalma left a reply on Using Related Model True/false Functions In Eloquent Queries

The definition of the Accessor requires specific naming structure.

In your case it would be GetLatestassignmentAttribute the Get and Attribute portion of the naming performs some Larvel magic.

Defining An Accessor To define an accessor, create a getFooAttribute method on your model where Foo is the "studly" cased name of the column you wish to access. In this example, we'll define an accessor for the first_name attribute. The accessor will automatically be called by Eloquent when attempting to retrieve the value of the first_name attribute:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    /**
     * Get the user's first name.
     *
     * @param  string  $value
     * @return string
     */
    public function getFirstNameAttribute($value)
    {
        return ucfirst($value);
    }
}

Dalma left a reply on Using Related Model True/false Functions In Eloquent Queries

Typically you would use an Accessor for this type of dynamic field generation.

Have you reviewed: https://laravel.com/docs/5.8/eloquent-mutators

06 Sep
1 week ago

Dalma left a reply on Percentage Difference Between Dates

Basically you would need at least three dates to create a percentage as a percentage is a ratio.

As an example you if you wanted to know today as a percentage of days in the month. You would need the start date, end date and today's date.

Aug 1 -> Aug 30 is 30 days Aug 1 ->Aug 6 is 6 days

Your percentage comes as 6/30 = .2 or 20%

Date calculation example https://laracasts.com/discuss/channels/general-discussion/difference-between-two-carbon-dates

28 Aug
2 weeks ago

Dalma started a new conversation Forge Branch

Hi I have both a production site and testing site maintained via Forge. Until today both production and testing were set up to use my Master branch which was based on Laravel 5.7. I want to move to Laravel 5.8 so I created a branch (called Upgrade-to-5.8) and with my IDE worked through the various issues.

I now have both Master and Upgrade-to-5.8 branches available on Github.

In Forge I accessed my test server site and changed the Deployment Branch from Master to Upgrade-to-5.8 and ran Deploy Now. Below is a portion of the deployment log where it appears that the master branch was deployed rather than my Upgrade-to-5.8 branch.

Is there something else that I need to do to change my branch on this site?

Wed Aug 28 21:12:57 UTC 2019
From github.com:XXXXXX(Changed for security purposes)
 * branch            master     -> FETCH_HEAD
Already up to date.
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating optimized autoload files
20 Aug
3 weeks ago

Dalma left a reply on How To Sync Attributes In A Specific Order ?

On my pivot tables I always add an id field and make it the primary index just like every other table used within Laravel. This would provide you with a method to sequence your records if you managed the sequence when they are created via the previously described ->attach method.

06 Aug
1 month ago

Dalma left a reply on Error In Migrate In Laravel 5.5

Can you also share your migration file?

01 Aug
1 month ago

Dalma left a reply on Tips For Seeding Production Tables From Devel Environment

That is a great idea thank you!

Dalma started a new conversation Tips For Seeding Production Tables From Devel Environment

What are others doing to seed tables when they are created in production environment.

I'm in the progress of moving from a hardcoded menuing structure to a table driven one using brand new tables. My development environment has the menus populated but as I release my code to production these tables will need to be populated immediately. Are you doing something at a database utility level or creating seeders?

16 Jul
2 months 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
2 months 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
2 months 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 months 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 months 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
2 months 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
3 months 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
3 months ago
10 May
4 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
4 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
4 months ago
06 May
4 months ago

Dalma left a reply on [Solved] Cannot Read Html Element Data Attribute

I was successful with this format for reading data attributes

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

28 Apr
4 months ago

Dalma left a reply on Commit To Forge Server Error

That is great news

27 Apr
4 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
4 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
4 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
5 months ago

Dalma left a reply on Unexpected Else

No the conditionals flow as follows:

@if 
@elseif
@else 
@endif

or

@if 
@elseif 
@endif

Dalma left a reply on Unexpected Else

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

You have an extra @else and @endif in the posted code

Dalma left a reply on Blade @if @else

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

10 Apr
5 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
5 months ago

Dalma left a reply on Eager Load

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

25 Mar
5 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
6 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
6 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