skoobi

skoobi

Ceredigion

Hire Me

Member Since 4 Years Ago

Experience Points 34,720
Experience
Level
Lessons Completed 232
Lessons
Completed
Best Reply Awards 8
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

09 Jan
1 week ago

skoobi left a reply on Spatie Backup And Mysqldump

Hi @snapey. It's running under root. I'm presuming it has the correct rights to see the folder, its all set up using Forge. The rest of the crons work.

skoobi left a reply on Spatie Backup And Mysqldump

Ye that command works perfectly. This is what's confusing me!

skoobi left a reply on Spatie Backup And Mysqldump

Hi @dalma. Ye sure, In the config it has an array to specify a disk to backup to so

'destination' => [

         /*
          * The disk names on which the backups will be stored.
          */
         'disks' => [
             'local',
         ],
     ],

I have it set to ftp. and the connection is good and all works when running the backup via the console.

skoobi started a new conversation Spatie Backup And Mysqldump

Hi. Im getting an error when backing up to an ftp server through a task schedule.

The error is ::

Exception message: The dump process failed with exitcode 127 : Command not found : sh: 1: /usr/bin/mysqldump: not found

Now i know its installed because, well I installed it and i can run it from /usr/bin/mysqldump and if i run the command to backup from ssh it also works fine. But when its scheduled it just keeps failing.

On my testing server which is an exact duplicate of the production server, it works perfectly!

Heres some of the code:::

Kernel.php

$schedule->command('backup:run --only-db')->everyThirtyMinutes()->environments(['production']); // set to 30min for testing...

config/database.php

'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
            'dump' => [
                'dump_binary_path' => '/usr/bin',
            ]
        ],

Any ideas. According to spatie its a server config issue but if I can run it via the command line on the server, surely it should work from the schedule...

Cheers

06 Jan
2 weeks ago

skoobi left a reply on OrderBy Not Quite How I Want It!

Ah, thank you, guys. I'll try that in a bit and report back.

05 Jan
2 weeks ago

skoobi left a reply on OrderBy Not Quite How I Want It!

Hi @snapey They go from A then BT, TF so Laravel is doing as it should but is there a way to order them by the string and numeric so its like so::

A101 A102 A111 A1101 BT101 BT134 TF455 TF456 etc.

whats happening at moment is

A101 A1001 A1002 A102 A1020

BT101 BT134 TF455 TF456

Cheers

skoobi started a new conversation OrderBy Not Quite How I Want It!

Hi.

I have a search query which grabs all the users and orders them by username.

In the search i use ->orderBy('username', 'asc') which will order them to a point...

The issue I'm getting is if say username is, A100 and then there's A1000 its order is then A100, A1000, A1001, A1002 etc and later when it gets to A110 it then goes A1100 etc.

Is there a way to order them correctly.

Cheers

03 Jan
2 weeks ago

skoobi left a reply on Strip .php From Url

Ok so after a lot of digging around and learning about Nginx i found a solution...

In the nginx config file i added ::

rewrite ^/registration.php /registration permanent;

This works perfectly.

skoobi left a reply on Strip .php From Url

Sorry, Ive tried all sorts now and it fails on the Forge Digital ocean server using Nginx...

Locally it works perfect using Valet but as soon as its on the DO server i get No input file specified.

I cannot figure it out at all. Any ideas??

This is my middleware that catches all requests ::

public function handle($request, Closure $next)
    {
        if (str_contains($request->url(), '.php')) {
            $url = str_replace('.php', '', $request->url());
            return redirect($url);
        }
        return $next($request);
    }

Cheers

31 Dec
2 weeks ago

skoobi left a reply on Strip .php From Url

Would that go in the

server {
$withoutExt = preg_replace('/\.[^.\s]{3,4}$/', '', $filename);
}

skoobi left a reply on Strip .php From Url

Thank guys. Im using nginx on forge. Im not going to lie but ive not used nginx before and a liitle afraid of messing with it.

But as a fix for now, I made a middleware to process the request and check for the extention and remove it then redirect to the correct location

if (str_contains($request->url(), '.php')) {
            $url = str_ireplace('.php', '', $request->url());
            return redirect($url);
        }

skoobi left a reply on Forward Non Www To Www In Forge?

Sorry. Ive got a workaround for now...

I created a middleware to deal with the request.

public function handle($request, Closure $next)
    {
        if (str_contains($request->url(), 'https://my-app.uk')) {
            return redirect('https://www.my-app.uk');
        }
        return $next($request);
    }

Happy new year everyone :)

skoobi left a reply on Strip .php From Url

I have a URL on some old site links that at the moment usehttps://www.my-app.com/regestration.php, on the new app that should be going to https://www.my-app.com/regestration so by removing the .php from the end it will return the correct url.

skoobi left a reply on Forward Non Www To Www In Forge?

Hi, thank you for the reply. I tried that but unfortunately due to restrictions to the way the servers and old app was set up, I have some code that distinguishes the environment then sets the subdomains.

if (App::environment('local')) {
    $sub = '';
    $domain = 'my-app';
    $tld = '.test';
} elseif (App::environment('testing')) {
    $sub = 'testing.';
    $domain = 'my-app';
    $tld = '.uk';
} elseif (App::environment('production')) {
    $sub = 'www.';
    $domain = 'my-app';
    $tld = '.uk';
}

Route::domain($sub . $domain . $tld)->group(function () {
    Route::get('/testing', '[email protected]');
    Route::post('/testing', '[email protected]');
    Route::middleware(['guest'])->group(function () {
        Route::get('/{page?}', 'Frontend\[email protected]');
    });
});

Makes it a little more interesting lol.

skoobi started a new conversation Forward Non Www To Www In Forge?

Hi how do i forward requests to a certain routes file to www?

Many thanks

skoobi started a new conversation Strip .php From Url

Hi. Is there a way to strip any .php filenames from the end of the url.

Im using Forge and Digitalocean but was wondering if theres a way to do it through middleware?

Cheers

29 Dec
3 weeks ago

skoobi left a reply on 500 Error - Laravel Project Deployment On Shared Hosting

No problem. Did it work? If so mark the best answer.

Cheers

skoobi left a reply on 500 Error - Laravel Project Deployment On Managed Hosting

In the file structure you have there, in public the index should be the index.php not html. I’m the index.php it with have the route to the main app

28 Dec
3 weeks ago

skoobi left a reply on Connecting To Database From Local Machine

Sorry! Found the issue. Changed the port to 3307 and all worked. Cheers @d

skoobi left a reply on Connecting To Database From Local Machine

Sorry for the late reply guys...

I tried the tunnel but doesn't work for some reason. Once I have a bit more time to check it out I'll post back.

What ive done for now is used Brew to install MySQL on my local machine and MacBook and then just used it like that without connecting to the test DB server. Its a bit of a pain as I don't have the same data throughout all machines but I can live with it.

skoobi left a reply on Laravel Forge Scheduled Job No Such File Or Directory?

It may be an idea to check the Laravel error logs on the forge server to see if something has been logged there.

The second part is the schedule will use the time from the kernel file. So if you set the job to run daily in the kernel file then it will run daily.

20 Dec
1 month ago

skoobi started a new conversation Connecting To Database From Local Machine

Hi.

I've got 2 servers setup with Digital ocean which was provisioned using forge. I have one as an app server and the other a database server.

I can connect using ssh tunnel on sequel pro but unless I add my IP to the firewall in forge, I cannot connect to the server when using local dev. I try to use a testing db on the server so when I'm away from the office I can carry on with local dev with the same data.

Any ideas on how to allow my local computer to connect ??

Cheers

18 Dec
1 month ago

skoobi left a reply on Cashier Error, Name Cannot Be Null

Hi, @globals. Ye, I knew it wasn't passing but wasn't sure why as it was all fine on stripe end.

But figured it out by accident when tidying up the code.

So i done::

// This 
$product = $user->pricing->stripe_product_id;
$plan = $duration . 'months';

// Params 1. Product 2. Plan
$user->newSubscription($plan, $plan)->create($stripeToken, [
    'email' => $user->email,
]);

// Instead of this
$user->newSubscription($user->pricing->stripe_product_id, $duration . 'months')->create($stripeToken, [
    'email' => $user->email,
]);

And now all works normally.

skoobi started a new conversation Cashier Error, Name Cannot Be Null

Hi.

I'm just trying to get the subscriptions working but I keep hitting this error,

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null in 

Now I know it looks missing but that's all I'm doing so far is passing the data from vue to the controller and in the controller::

try {
            $user = User::where('id', Auth::id())->with(['pricing'])->firstOrFail();
            $duration = request('duration');
            $stripeToken = request('stripeToken');
           
            // Params 1. Product 2. Plan
            $user->newSubscription($user->pricing->stripe_product_id, $duration . 'months')->create($stripeToken, [
                'email' => $user->email,
            ]);

            return response()->json(['status' => 'Your payment has been successful.'], 200);
        } catch (\Exception $e) {
            event(new NotifyIssues($user, $e));
            $request->session()->flash('status', $e->getMessage());
            $request->session()->flash('alert', 'danger');

            return response()->json(['status' => $e->getMessage()], 422);
        }

It creates the subscription in stripe and does the payment, but doesn't save to the subscriptions table.

Any ideas? Or more to the point, what am i missing?

skoobi left a reply on Activity Log

Fixed....

Turns out that when logging an activity, if a client logs-in then it saves it like so

{"user":447}

and if its to do with changing a value

{"attributes":{"telephone":"123456789"},"old":{"telephone":"1234567890"}}

skoobi started a new conversation Activity Log

Hi.

I'm trying to use Spatie ActivityLog to display all the activities on a page but I keep getting,

Undefined index: attributes

It used to work but for some reason, its stopped.

Heres the Code

// Controller
public function show($id)
    {
        $user = User::find($id);
        $activities = Activity::where('causer_id', $user->id)->orderBy('created_at', 'desc')->get();

        return view('admin.customers.settings-history.show')->with([
            'activities' => $activities,
        ]);
    }

// Blade
        @foreach($activities as $activity)
            <tr>
                <td>{{ $activity->created_at->format('d/m/Y') }}</td>
                <td>{{ $activity->created_at->format('H:i a') }}</td>
                <td class="textLeft">
                    @foreach($activity->changes['attributes'] as $key => $val)
                    <strong style="text-transform: capitalize;">{{ $activity->description }}</strong> :: {{"$key"}} From "{{ $activity->changes['old'][$key] }}" to "{{ $activity->changes['attributes'][$key]}}"<br>
                    @endforeach
                </td>
            </tr>
            @endforeach

Any ideas or help would be grateful.

Cheers

17 Dec
1 month ago

skoobi left a reply on Search Query Issue

I think a good feature request for Laracast would be a "Are you sure you've checked your code?" Lol...

Thank you so much, I ended up just taking the value and name out of the all so it just grabs everything anyway.

Thank you

skoobi started a new conversation Search Query Issue

Hi. I'm trying to search users using scopes but when trying to search for all, it only returns the wrong data. I.e I have in the searches form a checkbox with "All" "Active" "in-Active" but if I choose all it returns only the active for some reason.

// Controller 

    $users = User::role('Customer')
            ->findMailCentre($request->get('mail_centres'))
            ->HasStatus($request->get('status'))
            ->region($request->get('region'))
            ->type($request->get('type'))
            ->scans($request->get('scans'))
            ->sms($request->get('sms'))
            ->with(['account', 'settings'])
            ->get();

        return $users;


// Model scope

public function scopeHasStatus($query, $status_id)
    {
        if (!$status_id) {
            return $query;
        }
        return $query->whereHas('account', function ($query) use ($status_id) {
            $query->orWhere('status_id', $status_id);
        });
    }

// Blade file
            <h3>Status</h3>
            <div class="broadcastWrapper">
                <p style="text-transform: uppercase;"><input name="status[]" type="checkbox" id="all_statuses" /> ALL</p>

                <div id="statuses">
                    @foreach($statuses as $status)
                    <p style="text-transform: uppercase;"><input name="status[]" value="{{ $status->id }}" type="checkbox"/> {{ $status->title }}</p>
                    @endforeach
                </div>
            </div>

Any help would be grateful.

Many thanks

11 Dec
1 month ago

skoobi left a reply on SHARED HOSTING PLESK + LARAVEL

The only thing I can think of is the ports. If your using SMTP on an insecure network then it's 25 or if it's secure it's 465 or 463 also try the encryption to tls

skoobi left a reply on SHARED HOSTING PLESK + LARAVEL

The mail host is normally something like

mail.domain.com

So in pleas when you setup a new email account you should be able to find the settings to setup that email address

05 Dec
1 month ago

skoobi left a reply on So, How Exactly Do You Get JQuery From Webpack To Work With Blade?

If it’s already compiled the you use

Or whatever the path to the app.js is

03 Dec
1 month ago

skoobi left a reply on Do "something" Once A Day In Laravel

If you get in touch with heroku support, they’re pretty good and can sort it out for you. But youll need a paid plan

skoobi started a new conversation Search For With Array But If Nothing Return All

Hi. I’m trying to get a filter running for a mass mailer that has multiple checkboxes, for example , all, pending, active etc. What I’m trying to get working is the return all if value is set to all.

What’s the best way of writing this. I’m using traits on the user model

Cheers

01 Dec
1 month ago

skoobi left a reply on Mail Not Sending Cc

Cheers for the reply. Hmm. Ye tried all them and nothing. Not quite sure what too do with it other than set another Mail::to to the 2nd email. If I use ->bcc() it sends 2 copies to the original user and ignores the addresses in the bcc. Strange. I'll be pushing the project up to the testing server in the morning, so may give it a shot to see its the localhost or something.

Cheers

skoobi left a reply on Php-cs-fixer Help

Cheers for the reply. I gave that a shot but it didn't do anything. Im not sure whats going on there. Ill give it another try in the morning just in case! Heres what I have in my .phpcsfixer

return PhpCsFixer\Config::create()
->setRules([
    '@PSR2' => true,
    'array_syntax' => ['syntax' => 'short'],
    'no_unused_imports' => true,
    'ordered_imports' => ['sort_algorithm' => 'alpha'],
    'blank_line_before_statement' => ['if']
])

skoobi started a new conversation Php-cs-fixer Help

Hi.

I have got Php-cs-fixer up and running and its doing its thing, but I want it to automatically add a line above and below if else statements, i.e::

// from this 

if ($payment_type == 1) { // New Account
    $update_duration = $this->updateDuration($user, $duration);
    $update_balance = CustomerCreditBalance::where('user_id', $user->id)->update(['current' => 20 - ($balance_transaction->fee / 100),]);
    $account = CustomerAccount::where('user_id', $user->id)->update(['status_id' => 3]);
    $payment = Ledgers::save($user, $transaction_type, $cost, $charge->id, null, $payment_title . ' - ' . $user->username, null, null, 5, $balance_transaction->fee / 100, 'Stripe');
    event(new AccountSetupComplete($user, $payment));
} elseif ($payment_type == 2) {   // Renewal 2-3

// To this

if ($payment_type == 1) { // New Account

    $update_duration = $this->updateDuration($user, $duration);
    $update_balance = CustomerCreditBalance::where('user_id', $user->id)->update(['current' => 20 - ($balance_transaction->fee / 100),]);
    $account = CustomerAccount::where('user_id', $user->id)->update(['status_id' => 3]);
    $payment = Ledgers::save($user, $transaction_type, $cost, $charge->id, null, $payment_title . ' - ' . $user->username, null, null, 5, $balance_transaction->fee / 100, 'Stripe');
    event(new AccountSetupComplete($user, $payment));

} elseif ($payment_type == 2) {   // Renewal 2-3

Any ideas on how to do it. I can seem to find the settings in the docs.

Cheers

skoobi started a new conversation Mail Not Sending Cc

Hi. Im trying to add cc to the Mail::to() and for some reason (probably me) its not working.

Mail::to($event->user->email)->cc('[email protected]')->send(new AccountRenewalEmail($event->user, $mailcentre, $payment));

It sends to the user but not the cc, an ideas?

Many thanks

29 Nov
1 month ago

skoobi left a reply on Integrity Constraint Violation: 1048 Column 'category_id' Cannot Be Null (SQL: Insert Into `posts`

I didn’t spot that on my phone lol. I knew it was something not being passed through.

skoobi left a reply on Integrity Constraint Violation: 1048 Column 'category_id' Cannot Be Null (SQL: Insert Into `posts`

Have you dd($request->all()) the request to see what it’s outputting. If I your getting an error saying it can’t be null then It’s not passing through the category, so you need to check that.

If your not expecting the category to be selected or to have any data passed then you need to setup the database column to allow null. So in the migration

$table->integer(‘category_id’)->nullable();

skoobi left a reply on Validation In Controller

When you say the validation fails, do you get an error or does it just redirect back with nothing.

If it’s redirected back with nothing, have you got the errors being displayed like so: ‘’’ @if ($errors->any())

@endif ‘’’

skoobi left a reply on Integrity Constraint Violation: 1048 Column 'category_id' Cannot Be Null (SQL: Insert Into `posts`

Is the form passing the $request->category_id correctly.

It looks like there’s no value being passed.

skoobi left a reply on Project Wont Load Files In Public

Have you checked the .env file to make sure it’s all the same. If your using the env_url and it’s different in either env files then it may point to the wrong location. Also how are you calling the app.js and app.css

skoobi left a reply on Laravel Date Comparison

Im an idiot!!!!

Theres a very good reason it wasn't working as expected...

Changed the disable to disabled :) ... I want to cry.

<input type="submit" value="GO TO MY SHOPPING BASKET" @if($expiry <= \Carbon\Carbon::today()->addDays(7)) disabled @endif >

skoobi left a reply on Laravel Date Comparison

Just check the values and they're correct. Ive been pulling my hair out on this thinking it was the query I was asking, but seems its something else. Ill see if I can dig a bit deeper and figure it out.

Cheers

skoobi left a reply on Laravel Date Comparison

Hmm... I tried that as well and that didn't work either... Im going to have to look at the code and see what the heck going on!!! Or leave it as a bug for later :)

skoobi left a reply on Laravel Date Comparison

Thank you but unfortunately that didn't work... It just keeps showing!!!

Heres the dates ::

$expiry = 2018-12-05; // Should enable the button as its pithing 7 days of today
$expiry = 2018-12-07; // Should disable as its 8 days away

// Its parsed by carbon so I can use methods on the variable i.e. $expiry->addDays(7)

I just can't figure out whats going on!!

skoobi started a new conversation Laravel Date Comparison

Hi. For some reason my head wants to explode every time I get to this, and for some reason I just can't figure it out out even though its pretty straight forwards.

Im using Carbon for the dates and what I am trying to do is enable and disable a button in blade depending if the customers expiry date is due (within 7 days) or not.

So my logic is that I need to check that the $expiry is after Carbon::today()!!!

So in code it is ::

@if($expiry >= \Carbon\Carbon::today()->subDays(7)) disable @endif

But this doesn't disable the button!

Any ideas ?

many thanks

skoobi left a reply on I Cant Use Homestead

Paste your homestead.yaml here.

Also check you have typed it correctly in your homestead file and also make sure the spacing is correct in the gutter.

28 Nov
1 month ago

skoobi left a reply on Valet, PHP Installation Appears To Be Missing The MySQL Extension

Ah if you dig around, there is a fix for the Mojave issue. I had the same issue but found a solution. I’ll see if I can find it for you in the morning

skoobi left a reply on Valet, PHP Installation Appears To Be Missing The MySQL Extension

Hmm. I just checked through the Brew commands and you could try brew upgrade php and see what that comes up with. Or brew doctor to see if theres any issues with it