undefined_variable

undefined_variable

Member Since 4 Months Ago

Experience Points
1,610
Total
Experience

3,390 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
12
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

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

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

Level 1
1,610 XP
Aug
27
1 month ago
Activity icon

Started a new conversation Is This A Bug Or A Feature

So I have these 2 queries, and I pass quotesTotal and quotesToday to the view.

$quotes = Quote::where('owner_id', Auth()->id());

        $quotesTotal = $quotes->count();

        $quotesToday = $quotes
            ->whereYear('created_at', date('Y'))
            ->whereMonth('created_at', date('m'))
            ->whereDay('created_at', date('d'))
            ->count();

However I wanted to add a exclusion, so I change to this, and I noticed it effects both quotesTotal and quotesToday

$quotes = Quote::where('owner_id', Auth()->id());

        $quotesTotal = $quotes->where('internal', '!=', 1)->count();

        $quotesToday = $quotes
            ->whereYear('created_at', date('Y'))
            ->whereMonth('created_at', date('m'))
            ->whereDay('created_at', date('d'))
            ->count();

I dont understand how it can effect quotesToday variable.

telescope log

select
  count(*) as aggregate
from
  `quotes`
where
  `owner_id` = 91
  and `internal` != 1
select
  count(*) as aggregate
from
  `quotes`
where
  `owner_id` = 91
  and `internal` != 1
  and year(`created_at`) = "2019"
  and month(`created_at`) = "08"
  and day(`created_at`) = "27"```
Aug
23
1 month ago
Activity icon

Started a new conversation Stripe Webhook Route In Api.php Or Web.php And Exclude Csrf

Hi,

Everything I've searched for seems everyone puts the route in web.php and excludes the csrf.

However all the awnsers are old and maybe thats how it needed to be done then.

Is there any reason or security risk to not just put the route in api.php and therefore no need to worry about csrf?

Jul
30
2 months ago
Activity icon

Replied to My Forge Nginx Config Gives A Error

Seems there was some redirects in those files for the www, and the subdom

so i just changed to this and all seems great.

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name mysite.com.au;
    root /home/forge/mysite.com.au/public;
Activity icon

Replied to Git Cant Push, Deleted Files From The Gui

Thanks,

I went with git push --force.

seems to be ok

Activity icon

Started a new conversation Git Cant Push, Deleted Files From The Gui

Hi,

So I wanted to add some files to my ignore file, however they had been previously tracked,

so I logged into the gui and manually deleted them,

I still want the files locally, just not on git.

now I cant push i get this error

hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

How do I fix this?

Activity icon

Started a new conversation My Forge Nginx Config Gives A Error

Hi all,

So ive set up a production site,

mysite.com.au

with aliases www.mysite.com.au . subdom.mysite.com.au

got the ssl.

Now im getting this error when I save the nginx config in forge

nginx: [warn] conflicting server name "www.mysite.com.au" on 0.0.0.0:443, ignored
nginx: [warn] conflicting server name "www.mysite.com.au" on [::]:443, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

this is my config, whats gone wrong?

# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/mysite.com.au/before/*;

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name mysite.com.au www.mysite.com.au subdom.mysite.com.au;
    root /home/forge/mysite.com.au/public;

    # FORGE SSL (DO NOT REMOVE!)
    ssl_certificate /etc/nginx/ssl/mysite.com.au/594396/server.crt;
    ssl_certificate_key /etc/nginx/ssl/mysite.com.au/594396/server.key;

    ssl_protocols TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384;
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/nginx/dhparams.pem;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    # FORGE CONFIG (DO NOT REMOVE!)
    include forge-conf/mysite.com.au/server/*;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }


      location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/mysite.com.au-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/mysite.com.au/after/*;

Jul
26
2 months ago
Activity icon

Replied to How To Install Phpmyadmin On Forge?

Cheers, will give workbench a go.

Jul
25
2 months ago
Activity icon

Started a new conversation How To Install Phpmyadmin On Forge?

Hi,

So I tried Bashy's best awnser in this thread and I have no luck

https://laracasts.com/discuss/channels/servers/phpmyadmin-on-forge

ran this

git clone --depth=1 --branch=STABLE git://github.com/phpmyadmin/phpmyadmin.git

then navigate to /etc/nginx/sites-available

sudo nano default

to add the location code, ive tried a few different spots, this seems like a good spot?


    # FORGE CONFIG (DO NOT REMOVE!)
    include forge-conf/default/server/*;

location /phpmyadmin {
    index index.php;
    auth_basic "Login";
    auth_basic_user_file /home/forge/default/phpmyadmin/authbasic_mysql;
}



    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/default-error.log error;

    error_page 404 /index.php;


   location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

restart server

sudo systemctl restart nginx

ive also added this sym link, but its unclear if this is still needed.

sudo ln -s /home/forge/default/phpmyadmin /usr/share/nginx/html

restart server again

sudo systemctl restart nginx

navigating to http://IP-ADDRESS/phpmyadmin/index.php

gives a error

No input file specified.

navigating to http://IP-ADDRESS/phpmyadmin

gives a error

403 Forbidden

So yeh, safe to say I have no idea what im doing.

Jul
24
2 months ago
Activity icon

Replied to Redirect 13000 Pages With .html To Laravels Pretty Urls

I've tried that and doesn't seem to work.

should this even work on local dev with 'php artisan serve'

this is my htaccess

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    RewriteRule ^(.*)$ .html
    
    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
Activity icon

Started a new conversation Redirect 13000 Pages With .html To Laravels Pretty Urls

Hi,

I need to Redirect 13000 pages with .html to laravels pretty urls

So I have about 13000 dynamically generated pages from a database call, that get good seo.

Now I've rewritten in laravel.

I've searched and found some solutions good for 1 or 2 pages.

can I wildcard this in htaccess?

Jul
21
2 months ago
Activity icon

Replied to How To Get The Last Child Of A HasMany Relationship For All Parents

return $this->hasOne(Measure::class)->latest()->first();

gives this error:

BadMethodCallException Call to undefined method App\Comment::addEagerConstraints()

but this works ok

return $this->hasOne(Measure::class)->latest();

why?

Jun
03
4 months ago
Activity icon

Replied to Displaying The Users Balance For Each User.

After a huge amount of head bashing , I found bobbybouwmann answer here https://laracasts.com/discuss/channels/eloquent/sum-relationship

All I need to do is this, no need to loop in a loop. lolz.

{{ ($user->accounts->sum('credit') - $user->accounts->sum('debit')) }}
Activity icon

Started a new conversation Displaying The Users Balance For Each User.

Hi,

I am listing all the users in the index view and I want to show the users account balance next to each user. This is as far as I have got, When I loop inside the loop, I need the count, but not sure how?

UsersController.php

public function index(User $user, Request $request)
{
    $users = User::with('accounts');
       
    $users = $users->paginate(10)->appends(request()->query());

    return view('admin.users.index', compact('users'));
}

User.php

public function accounts()
{
    return $this->hasMany(Account::class, 'owner_id');
}

index.blade.php

 <th>ID</th>
 <th>Name</th>
 <th>Balance</th>
   @foreach ($users as $user)
<tr>{{$user->id}}</tr>
<tr>{{$user->name}}</tr>
<tr>
  @foreach ($user->accounts as $account)
           {{ ($account->credit - $account->debit) }}   // need to count the value of this.
   @endforeach

</tr>
@endforeach