aurawindsurfing

aurawindsurfing

Laravel Newbie at @

Member Since 2 Years Ago

Dublin, Ireland

Experience Points
186,410
Total
Experience

3,590 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
962
Lessons
Completed
Best Reply Awards
124
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 38
186,410 XP
Nov
10
2 days ago
Activity icon

Replied to Googlebot Cannot Access Images Hosted On CloudFront - Reports Blocked By Robots.txt

Hey @thebigk

This might be long shot but is there a way to sitemap your images and give it to google that way?

Here is some info I found: https://support.google.com/webmasters/answer/178636?hl=en

Activity icon

Replied to Make An Appointment System

@hafizurupm it is the right place to learn how to make such a system for sure.

Start from https://laracasts.com/series/laravel-6-from-scratch

This will give you a good idea where you should start.

Nov
09
3 days ago
Activity icon

Replied to Comparing Services For Cheap Cloud Hosting And Storage (Cloud / AWS / S3 / Amazon Cloudfront / ... ???)

Hey @connecteev

AWS <> as close to free as possible
as fast as possible <> as close to free as possible

If you want something free and really well thought then go and try https://www.netlify.com/ this might serve your goal with few tweaks.

Hope it helps!

Nov
07
5 days ago
Activity icon

Replied to Remote Model

Hey @poxin

Trucker looks more like for mapping resources. What you need it to possibly Cache your responses from API to have some sort of safety on your side when API will be down. This way you will have old data to work with or by setting expiry on Cache you will actually limit your API queries.

Just an idea.

Hope it helps!

Activity icon

Replied to Dealing With Git - Main Package And Subpackages

Why not do simple bash script for your project?

https://laravel-news.com/bash-aliases

Have it chained in one command and commit all of them at once, maybe even detect if there was a change and and only then commit that submodule?

Hope it helps!

Nov
04
1 week ago
Activity icon

Awarded Best Reply on Oci8 Exception - Laravel On Centos 7

Hi @konrms

I have a similar setup working. Some points from my notes that might help you troubleshoot.

Did you add

extension=oci8.so

to your php-fpm.ini?

check if it is installed:

php -m | grep oci

or

<?php phpinfo(); ?>
i
print_r(get_loaded_extensions());

test connection from your app:

$conn = oci_connect("USER", "passwprd", "localhost/xe");
 echo $conn;

Only here install yajra

Hope it helps!

Nov
02
1 week ago
Activity icon

Replied to Proper Way To Run Laravel Queue In Docker

Hey @region23

This solution does not run your Queue Worker in docker. It runs a command from outside of your docker container to run in a docker container called php

I stopped working with docker but the idea will be to run this command from within the container and actually build it with it already set up. Go back to the thread you are referencing and you will see that you answer is voted -3

https://stackoverflow.com/questions/48884802/docker-laravel-queuework

Go for one of the accepted solutions.

Hope it helps!

Activity icon

Replied to Oci8 Exception - Laravel On Centos 7

No worries! Oracle Magic!

Activity icon

Replied to Oci8 Exception - Laravel On Centos 7

Hi @konrms

I have a similar setup working. Some points from my notes that might help you troubleshoot.

Did you add

extension=oci8.so

to your php-fpm.ini?

check if it is installed:

php -m | grep oci

or

<?php phpinfo(); ?>
i
print_r(get_loaded_extensions());

test connection from your app:

$conn = oci_connect("USER", "passwprd", "localhost/xe");
 echo $conn;

Only here install yajra

Hope it helps!

Activity icon

Replied to How To Make Laravel Load Very Fast

Is this a question or a statement? 😃

Activity icon

Awarded Best Reply on Limit The User Login To Specific Time Period

@itxrahulsingh read the docs carefully.

The way this works is that request to your app will hit every middleware each time you ask for anything. This is how login of users works. Here, for example, you have default middleware that is already in use in your app:

protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            // \Illuminate\Session\Middleware\AuthenticateSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],

        'api' => [
            'throttle:60,1',
            'bindings',
        ],
    ];

So before anything happends in your app it already check for:

  • cookies
  • sessions
  • authenticated sesssions
  • errors in session
  • csrf token

So it already checks if user is logged in. You only need to add another one that will let users log in only within working hours.

It will always work for every request to your app.

Hope it helps!

Activity icon

Replied to How To Query Database For Each Day In An Array Of Days Laravel

Hey @farshadf

Modify it to your needs but something like that will do the trick:

$room_capacity = Capacity::query()
            ->whereBetween('date', [
                Carbon::now()->startOfMonth()->subMonth()->toDateString(),
                Carbon::now()->startOfMonth()->subMonth()->endOfMonth()->toDateString(),
            ])
            ->get();

This here makes no sense:

->whereDate('from_date', '<=', $dates[$t])

It actually should be:

->where('date', '<=', $dates[$t])

Also if you try to do a booking system then try to think in a smallest possible interval when you think about your reservations. For instance if room can only be booked for 1 day, then instead of creating from_date to_date you could create 31 days in a given month and then create lets say 4 consecutive bookings for one day for that room - meaning it would be booked for 4 days.

This type of approach will make your system more flexible and easier to work with.

You can even go down to hours and book rooms per hours. Even go down to minutes etc etc. Your future queries would be much simpler then as well.

Hope it helps!

Activity icon

Replied to Limit The User Login To Specific Time Period

@itxrahulsingh read the docs carefully.

The way this works is that request to your app will hit every middleware each time you ask for anything. This is how login of users works. Here, for example, you have default middleware that is already in use in your app:

protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            // \Illuminate\Session\Middleware\AuthenticateSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],

        'api' => [
            'throttle:60,1',
            'bindings',
        ],
    ];

So before anything happends in your app it already check for:

  • cookies
  • sessions
  • authenticated sesssions
  • errors in session
  • csrf token

So it already checks if user is logged in. You only need to add another one that will let users log in only within working hours.

It will always work for every request to your app.

Hope it helps!

Activity icon

Awarded Best Reply on Laravel Delete Relationships On A Single Model?

Hi @zyxxyzyxz

Have a look here: https://laravel.com/docs/master/eloquent-relationships#updating-belongs-to-relationships

There are quite a few that you could use like

$user->account()->associate($account);
$user->account()->dissociate();

$user->save();

There is also one for pivots

// Detach a single role from the user...
$user->roles()->detach($roleId);

// Detach all roles from the user...
$user->roles()->detach();

Hope it helps!

Activity icon

Replied to Laravel Delete Relationships On A Single Model?

Hi @zyxxyzyxz

Have a look here: https://laravel.com/docs/master/eloquent-relationships#updating-belongs-to-relationships

There are quite a few that you could use like

$user->account()->associate($account);
$user->account()->dissociate();

$user->save();

There is also one for pivots

// Detach a single role from the user...
$user->roles()->detach($roleId);

// Detach all roles from the user...
$user->roles()->detach();

Hope it helps!

Activity icon

Replied to A Problem In Blade When Uses Eloquent

Hey @shirotzumiyake

@foreach ($reactions as $reaction)

Inside this loop you should call $reaction and not $react

Also try to move your logic to Controller that displays this blade. There should suppose to be as little logic in your views as possible.

Hope it helps!

Activity icon

Replied to User Auth From Mobile App

Hey @muazzamazaz

The simple answer "you can not".

While you access your app not from a browser then there is no cookies, no session etc.

What you need is JWT, have a look here: https://laravel.com/docs/5.8/passport

In a nutshell, you need to authorise every request that will hit your app's API.

Hope it helps!

Activity icon

Replied to How To Re-construct A Class In Single Process?

Hey @muzafferdede

It could be a bit long shot but did you consider using tap() when you look at the docs this helper looks somewhat underrated:

https://laravel.com/docs/master/helpers#method-tap

but if you look at how Taylor is using it: https://medium.com/@taylorotwell/tap-tap-tap-1fc6fc1f93a6

It makes all the difference! I bet you can use it for your Class as well.

Hope it helps!

Activity icon

Replied to Limit The User Login To Specific Time Period

@itxrahulsingh create additional middleware that check for office hours.

Check the docs here: https://laravel.com/docs/master/middleware#defining-middleware

Hope it helps!

Nov
01
1 week ago
Activity icon

Replied to Group-by Not Working With Order By Laravel Elequent

@farshadf I guess you need to go for a long long walk and look at it from distance.

You have quite experienced guys trying to help you here. I think you might be to fix on your way of doing things.

If you are trying to solve something with a monster query then it means that your whole app needs to be redesigned as it does not suit your purpose. Look at putting some of this directly on models that are involved. Then from use those models to simplify your controllers then break you query into smaller queries or query scopes etc etc.

Monster Queries are bad!

Happy Coding!

Oct
30
1 week ago
Activity icon

Replied to Group-by Not Working With Order By Laravel Elequent

@farshadf are you able to write the same query in MySQL IDE and get expected results? Maybe try this first and make sure your query works on MySQL level?

Activity icon

Replied to Group-by Not Working With Order By Laravel Elequent

Then he should run his method on results of groupBy it returns completely new set of records, this is why orderBy does not work I think.

Activity icon

Replied to Group-by Not Working With Order By Laravel Elequent

Hey @farshadf

Use sortBy instead of orderBy

Oct
29
2 weeks ago
Activity icon

Awarded Best Reply on Add If Condition In Controller?

Hey @andreixfr

public function edit($id)
    {
        $model = Models::with('model_media')->findOrFail($id);
        if(!isset($model->sort)){
        $data['allMedia'] = ModelMedia::where([["model_id", "=", $id]])->orderBy('sort')->get();
      }else{
        $data['allMedia'] = ModelMedia::where([["model_id", "=", $id]])->orderBy('sort', 'DESC')->get();
      }

Hope it helps!

Activity icon

Replied to Add If Condition In Controller?

Hey @andreixfr

public function edit($id)
    {
        $model = Models::with('model_media')->findOrFail($id);
        if(!isset($model->sort)){
        $data['allMedia'] = ModelMedia::where([["model_id", "=", $id]])->orderBy('sort')->get();
      }else{
        $data['allMedia'] = ModelMedia::where([["model_id", "=", $id]])->orderBy('sort', 'DESC')->get();
      }

Hope it helps!

Oct
26
2 weeks ago
Activity icon

Replied to Get Count In Multilple Models

Hi @untymage

Your code finds only 1 artist. It does not look for usages of tag pop

$artist = Artist::withCount('tags')->find($id);

$artist->tags_count;

Try:

$artist->albums->where('tags', 'like', '%' . 'pop' . '%')->count()

Hope it helps!

Activity icon

Replied to Mailgun

You add guzzle with composer.

You push to the server only composer.json

Server installs it while deploying your code or you install it by hand by running

composer install

on your server.

What are you using for deployement of your code?

Oct
25
2 weeks ago
Activity icon

Replied to Valet+ And Catalina

Hey @finchy70

First get a regular valet to work. Remove everything associated with valet and reinstall it completely.

It is questionable why Catalina should have anything to do with valet not working. It could be a simple restart of the machine that caused some changes to kick in that you have introduced yourself few weeks before.

Does valet start at all? What does it say when it starts?

What can you see when you run:

valet paths
valet links
Activity icon

Replied to How Can I Load Collection Data Into A Table?

Hi @myke2424

Something like that should do the trick for a start:

{{$months = collect(['Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec'])}}

<table class="table table-striped table-sm">
    <thead>
    <tr>
        <th scope="col">Month</th>
        <th scope="col">Overtime Hours</th>
        <th scope="col">Compensation Hours</th>
        <th scope="col">Vacation</th>
        <th scope="col">Personal Hours</th>
        <th scope="col">Sick Hours</th>
    </tr>
    </thead>
    <tbody>
    @foreach ($months as $month)
        <tr>
            <th scope="row">{{$month}}</th>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td>
        </tr>
    @endforeach
    </tbody>
</table>
Oct
10
1 month ago
Activity icon

Replied to Download PDF In Laravel Nova Action

@kidereo to download the file you need to send it to your browser as a response. Similar to what you do to send your browser to a view.

When you click something, just return from your controller Storage::download() that should do the trick.

Remember that you can download only one file that way.

Hope it helps!

Oct
06
1 month ago
Sep
25
1 month ago
Activity icon

Replied to How To Set Time Between Reports Of Users?

Hi @andreixfr

Enable button if:

$last_report = $user->reports->latest()->first()->get();
if ($last_report->created_at < Carbon::now()->subMinutes(5)->toDateTimeString()) {
// show modal button
}
Activity icon

Replied to Laravel Cashier - Undefined Variable: Token

@wallyj

When you installed laravel did you install the latest version? Version 6.0.x does not support Braintree as far as I'm aware:

https://laravel.com/docs/6.x/braintree

but 5.8 does:

https://laravel.com/docs/5.8/braintree

Check version of your Cashier as well. I think this is the highest that supports Brainthree but I could be wrong: https://github.com/laravel/cashier/releases/tag/v9.3.5

Hope it helps!

Sep
22
1 month ago
Activity icon

Replied to JWT TOKEN WEB APP

Hey @gustavocassoto

You can pass token in the header of your http request as well.

Activity icon

Replied to Don't Touch!

Hey @arketekt

Yes this is exactly the way you should do this:

php artisan vendor:publish

The overwrite anything you like in resources/views In those views there should be references to the styling files so you might just want to write your own styles and drop the basic ones.

Hope it helps!

Sep
12
2 months ago
Activity icon

Replied to Dashboard View: Using Filters On Collection

Hey @wva

Why not simply do in blade:

$team->upcomingEvents()->oldest()

Or whatever way you decide which one is coming up next.

Activity icon

Replied to How To Change The Button Into Badge, If It Is Already Approved?

What are you using to do this? You would typically do this with javascript so when some property changes the badge appears.

Activity icon

Replied to Deploying Laravel Project On GoDaddy Server

Do you have access to the console of that server?

You should run:

php artisan key:generate

Hope it helps!

Sep
10
2 months ago
Activity icon

Replied to Laravel Messenger Package

Here is a simple 1-1 messaging package if anyone is looking for this: https://github.com/aurawindsurfing/messenger

Sep
04
2 months ago
Activity icon

Replied to Model Factory In Package

Spot on @rugavy thanks!

Activity icon

Replied to Setup A Shop.stechmax.com

Hey @successdav

Just think about it as a complete separate website that happen to have address shop.stechmax.com

From here it is just any ecommerce solution that you are looking after, wheater it will be laravel, shopify or anything else.

There is hundreads of materials how to to set up ecommerce out there.

Sep
03
2 months ago
Activity icon

Replied to Migrations Are No Longer Autoloaded Since Laravel 5.5?

Hey @bobbybouwmann

I'm building my first package and was wondering why:

if (!class_exists(CreateSomeTable))

did not detect the migration files, which in turn caused duplicate migration files while publishing which in turn caused the whole thing to crash ;-)

I changed the way I cjeck it in my ServiceProvider to:

if (empty(glob(database_path('migrations/*_create_messages_table.php'))))
            {
                $this->publishes([
                    __DIR__ . '/../database/migrations/0000_00_00_000000_create_messages_table.php' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_messages_table.php'),
                ], 'migrations');
            }

and now it is working as expected.

I was wondering however if there was any particular reason for them being excluded, other then making no sense to import them 😀

Activity icon

Started a new Conversation Migrations Are No Longer Autoloaded Since Laravel 5.5?

Hey Guys!

Just wonder if anyone can share with me why up until 5.4 everything in database folder was autoloaded:

"autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\": "app/"
        }
    },

but since 5.5 it is only factories and seeds that are autoloaded.

"autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\": "app/"
        }
    },

Could not find the pull request on github for this.

Thanks!

Aug
29
2 months ago
Activity icon

Replied to Undefined Var In Vue.js

In console it should give you the line. If not then it is the first place you try to use this variable.

Aug
27
2 months ago
Activity icon

Replied to Add New Comment Syntax For Blade: ';;' ?

Hey @miwal

I just wonder, why would you write comments in your blade files at all? If you find yourself writing comments then your code is not clear to understand IMHO. Not that Laravel Core does not have lots of comments 😀

Activity icon

Replied to How Many Controllers For The Same Thing?

Hey @barley

Did you see this video? It might answer some of your questions:

Cruddy by Design

Activity icon

Replied to Laravel ID Authentication With Users From Multiple Tables

Hey @dennys

Two problems here:

You should login only your users. Think about it. Every Trainer Formatore is a user. So just login users.

Second change the default field for user like in the documentation: https://laravel.com/docs/master/authentication#included-authenticating

Username Customization By default, Laravel uses the email field for authentication. If you would like to customize this, you may define a username method on your LoginController:

public function username()
{
    return 'username';
}

Hope it helps!

Activity icon

Started a new Conversation Better Model Relationship

Hi Guys. I need some help with making my relationship query better. I have 4 columns like so:

users
user_id

vendors
id
user_id

jobs
id
user_id

offers
id
vendor_id

This is the query I came up with to display Vendor Jobs via offers that he placed. So user owns the jobs and vendors can place offers on them. Here is the query:

public function closedJobs()
    {
        return Job::whereState('closed')->with(['offers' => function ($offers) {
            $offers->whereVendorId($this->id);
        }]);
    }

Any way to handle it better? I did not want to install any third party packages like hasManyThroughDeep I want to use plain laravel eloquent only no RAW queries.

Thanks!

Activity icon

Replied to Quill Editor Integration With Laravel 5.8

Sorry - edited my answer:

Do:

npm install quill

in terminal while being inside you application folder.

Edit /resources/js.app.js after

window.Vue = require('vue');

add

import Quill from 'quill';

Vue.use(Quill);

In your webpack.mix.js

Make sure it is part of the mix:

mix.js('resources/js/app.js', 'public/js')
    .sass('resources/sass/app.scss', 'public/css');

run npm run dev

Now it should be available to you.