skoobi

Member Since 4 Years Ago

Ceredigion

Experience Points 38,200
Experience Level 8

1,800 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 260
Lessons
Completed
Best Reply Awards 8
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.

12 Jun
1 month ago

skoobi started a new conversation Firefox Content Security Policy

Hi. Im in the middle of updating the Stripe payments and found an issue when it redirects to the payments page.

Im getting Content Security Policy: The page’s settings blocked the loading of a resource at eval (“script-sr

It only happens in Firefox and works perfect in chrome and safari.

Ive added a meta header <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' http://* 'unsafe-inline'; script-src 'self' http://* 'unsafe-inline' 'unsafe-eval'" /> to see if that works but nothing...

Any ideas?

Cheers

11 Jun
1 month ago

skoobi left a reply on New CSS Only Updates When Hard-refreshing(ctrl + F5)

Its to do with the browser. I went mad trying to figure out why my css wasnt updating when changed. Turned out Chrome and Safari caches the css and js files. Depending on which you use you can disable it to cache that url.

10 Jun
1 month ago

skoobi left a reply on Auth Login Shows 419 Page Expired On POST Request

I think this is the same as what i had on an app previously. But what i done was catch the error in the Handler.php file and then redirect back with a message.

public function render($request, Exception $e)
    {

        if ($e instanceof \Illuminate\Session\TokenMismatchException)
        {
            return redirect()
                    ->back()
                    ->withInput($request->except('password'))
                    ->with([
                        'status' => 'Oops! Your Validation Token has expired. Please try again',
                        'alert' => 'danger']);
        }   

        return parent::render($request, $e);
    }
05 Jun
1 month ago

skoobi left a reply on Redirecting Non-www To Www

Figured it out...

Cheers all for your help.

It turned out that it was trying to redirect non http instead of the https.

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
        server_name .my-app.com;
    rewrite ^(.*) https://www.expost.uk permanent;

        # FORGE SSL
}

This has worked for me

skoobi left a reply on Redirecting Non-www To Www

Hi @johnbraun. Thanks for the reply.

Im not too good with nginx and try to stay clear of it as best i can but I gave it a try and it didn't change anything on that.

Heres what I tried and its more than possible I have it wrong lol...

server {
    server_name my-app.com;
    return 301 http://www.my-app.com$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name .my-app.com;
    root /home/forge/my-app.com/public;

    # FORGE SSL (DO NOT REMOVE!)

Cheers

04 Jun
1 month ago

skoobi left a reply on Redirecting Non-www To Www

Hi @cronix. Cheers for the reply.

Ive got it redirecting the http to https already through nginx, but the issue I have is the app was setup in such a way that the routes splits it into subdomains, i.e. the front-end is www.my-app.com and the admin route is admin.my-app.com. I was hoping to find a way to do it in the nginx config but, I'm not so confident in poking around in the files.

I was hoping if there was a way in nginx to check if the uri has a www or admin before the .my-app.com and then if there is no www or admin just redirect to www, if that makes any sense at all...

When I add a redirect into nginx for non-www to www, if I goto admin.my-app.com it redirects to www.my-app.com.

Route::domain('www.my-app.com')->group(function () {
    // Front-end Routes
});

Route::domain('admin.my-app.com')->group(function () {
    // Admin Routes
});

skoobi started a new conversation Redirecting Non-www To Www

Hi. I've got an app which uses subdomain for the backend (admin.my-domain.com) and the frontend which is (www.my-domain.com) But if i goto my-domain.com without the www it will hit a 404.

I added a middleware to my 'web/routes.php' which handles the frontend pages to redirect to www but this doesn't work for some reason.

// Middleware file

if (App::environment('production')) {

            $host = $request->header('host');

            if (substr($host, 0, 4) != 'www.') {
                $request->headers->set('host', 'www.' . $host);
                return Redirect::to($request->path(), 301);
            }

        }
       return $next($request);

// Route/Web.php

Route::domain(config('settings.routes.domain'))->middleware(['redirect_to_www', 'redirect_if_logged_in'])->group(function () {
//
});

What would be the best way to have it check and redirect the frontend pages.

Cheers

25 Apr
2 months ago

skoobi left a reply on Syntax Error Or Access Violation: 1075 Incorrect Table Definition

Hi @devfrey. I checked it over this morning and found that it was due to me adding a length to the "tag_number" integer.

Changed $table->integer('tag_number', 11)->nullable(); to $table->integer('tag_number')->nullable(); and it worked. Im still not quite sure why, im sure i used to put a length into the integer before! May be my old age lol.

Many thanks

24 Apr
2 months ago

skoobi started a new conversation Syntax Error Or Access Violation: 1075 Incorrect Table Definition

Hi.

Im trying to setup a migration which on delete cascades but i keep getting the error::

SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key (SQL: create table `stock_list` (`id` bigint unsigned not null auto_increment primary key, `user_id` int unsigned not null, `name` varchar(255) null, `tag_number` int null auto_increment primary key, `notes` text null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

Heres my migration for the stock_list::

Schema::create('stock_list', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedInteger('user_id');
            $table->string('name', 255)->nullable();
            $table->integer('tag_number', 11)->nullable();
            $table->text('notes')->nullable();
            $table->timestamps();

            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
        });

I don't quite understand why this error is popping up and on another project which this was copied and pasted from (BirdBoard Tutorial) it works perfect)

Any help would be grateful

Cheers

11 Apr
3 months ago

skoobi left a reply on Valet Issues

Found a solution.

It looks like apache was running in the background which I think was stopping it from loading nginx etc.

Heres a link for some troubleshooting​ guides.

https://gist.github.com/adamwathan/6ea40e90a804ea2b3f9f24146d86ad7f#problem-im-getting-a-502-bad-gateway-error

After stopping apache and restarting valet it all worked.

skoobi started a new conversation Valet Issues

Hi.

For some reason yesterday, I switched my machine on and none of my test sites worked. I got the message "Failed to open page", "Safari cannot connect to the server".

I checked 'brew services list' and found that some are yellow and some are green. dnsmasq, nginx, php and redis are the ones in yellow and the rest are green. Yellow normally means it cannot get the status. All has been working perfectly​ up until​ yesterday. Nothing has changed on the system.

dnsmasq   started root       /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
[email protected] started root       /Library/LaunchDaemons/[email protected]
nginx     started root       /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
php       started root        /Library/LaunchDaemons/homebrew.mxcl.php.plist
[email protected]   started            /Library/LaunchAgents/[email protected]
redis     started root        /Library/LaunchDaemons/homebrew.mxcl.redis.plist

Things I've​ tried:

  • Update composer global
  • update brew
  • valet install
  • valet restart
  • Unlink from brew and install again

Nothing seems to have worked. Yesterday I switched the machine back of and then back on again and all was working, till this morning when I tried to access a different project and im getting the same as yesterday.

Any ideas?

Cheers

30 Mar
3 months ago

skoobi left a reply on This Connection Is Not Private

The only solution I can find is to use anything Firefox and then import the Valet certificate. https://github.com/laravel/valet/issues/296

skoobi left a reply on This Connection Is Not Private

I tried Firefox and chrome but same issue. I've un-secured the project and resecured and still the same Heres a more detaild error from firefox

myapp.test uses an invalid security certificate. The certificate is not trusted because the issuer certificate is unknown. The server might not be sending the appropriate intermediate certificates. An additional root certificate may need to be imported. Error code: SEC_ERROR_UNKNOWN_ISSUER

skoobi started a new conversation This Connection Is Not Private

Hi. Im using Safari and in the last few days, not sure if there was an update or what, but all my .test sites I have which are served by valet are now showing "This Connection Is Not Private" warning.

I've done the usual thing and "trust All" for the certificates but nothing seems to work. I just cannot access any of my .test sites through Safari. I know i can use Firefox or Chrome but I just like Safari .

Anyone else had this issue.

20 Feb
4 months ago

skoobi left a reply on Not Ordering OrderByRaw('SOUNDEX(username), LENGTH(username), Username Desc')

Ive tried several variations of

orderByRaw('SOUNDEX(username), LENGTH(username), username desc') 

but as an example If i am at user BT101 (last of the BT users) and then click previous, I would expect to get the last of the A users, so in this case A1476, but it doesnt. It jumps straight to A989 which is correct in terms of its the last user in that order if it was in numerical.

19 Feb
4 months ago

skoobi started a new conversation Not Ordering OrderByRaw('SOUNDEX(username), LENGTH(username), Username Desc')

Hi.

I'm having an issue when trying to order the users by username and using as a next / previous button!

I am using view composer to populate a sidebar that has a previous and next button.

I then get the current id from the URL segment and find the current user.

How i want them ordered is by Username as follows :::

A001 A009 A110 A212 A330 A789 A982 A1012 A1234

BT001 BT009 BT110 BT212 BT330 BT789 BT982 BT1012 BT1234

SA001 SA009 SA110 SA112 SA330 SA789 SA982 SA1012 SA1234

etc...

But they're not showing up like this. They either go from A1500 to A150 or when it get to the next row of usernames it just goes back the the start.

Here's the code i have already:::

 $user = Auth::user();
        $id = request()->route('id');
        $customer = User::where('id', $id)->first();
        $mail_centre_id = MailCentreHelper::get_mail_centre_id();


          
        $previous = User::where('username', '<', $customer->username)
                ->findMailCentre($mail_centre_id)
                ->orderByRaw('SOUNDEX(username), LENGTH(username), username desc')
                ->status([1,2,3,4,5,6,9])
                ->pluck('id')
                ->first();

          $next = User::where('username', '>', $customer->username)
                ->findMailCentre($mail_centre_id)
                ->orderByRaw('SOUNDEX(username), LENGTH(username), username asc')
                ->status([1,2,3,4,5,6,9])
                ->pluck('id')
                ->first();

Any help or ideas would be grateful..

Many thanks

07 Feb
5 months ago

skoobi left a reply on Urgent Help Needed, Even Google Couldn't Answer- Please Help. Laravel Test Fails..

Have you checked the test .env file. When you run tests, it creates a separate .env file to run.

You can create a .env.testing file to add your credentials etc for the test environment.

https://laravel.com/docs/5.7/testing

Thats my only idea on it i think. :)

skoobi left a reply on QueryException In Connection.php Line 770:

Looking at the result it may be its not passing 'stream_id' through.

If you don't need the stream_id (which looks like you may do) then you can set it to null in the database or nullable() in the migration.

30 Jan
5 months ago

skoobi left a reply on Looping Through A Json Object?

Sorry for the late reply. I don't seem to be getting any emails from Laracast!

I have done as you have here but I'm​ getting `Cannot use object of type stdClass as arr

The one thing which I need to try and get working is that telephone etc can change. I.e. it may be name or address etc Ive tried so many different things to try to get it to work that im at a loss.

I like the Accessors, I've ​learned​ something new :)

29 Jan
5 months ago

skoobi left a reply on Looping Through A Json Object?

Ok im pretty confused.

Ive tried to access

{
"type":"account",
"old":{
    "telephone":"12345678",
    "email":"[email protected]"
},
"new":{
    "telephone":"12345678333",
    "email":"[email protected]"}
}

By using

// Get the record
$data = CustomerActivity::where('user_id', $user->id)->get();
$activities = json_decode($data);


// In blade
@foreach($activities as $activity)
<tr>
    <td>{{ \Carbon\Carbon::parse($activity->created_at)->format('d/m/Y H:i:s') }}</td>
    <td class="textLeft">
         <strong style="text-transform: capitalize;">Old</strong>:: {{ $activity->data }} <br>
        {{-- <strong style="text-transform: capitalize;">New</strong>:: {{ $activity->data['new']['telephone'] }} --}}
    </td>
</tr>
@endforeach 

// The dd output
array:1 [▼
  0 => {#822 ▼
    +"id": 29
    +"user_id": 447
    +"data": "{"type":"account","old":{"telephone":"123456783","email":"[email protected]"},"new":{"telephone":"123456783333","email":"[email protected]"}}"
    +"old": null
    +"new": null
    +"type": null
    +"created_at": "2019-01-28 15:27:32"
    +"updated_at": "2019-01-28 15:27:32"
  }
]


// What I have tried
{{ $activity->data->new['telephone'] }}
{{ $activity->data['new']['telephone'] }}
{{ $activity['data']['new']['telephone'] }}
{{ $activity['data']->new['telephone'] }}
// Also user the $activity[0] etc.. Cant remember what gave me the 'data'. I think it was if I returned the $activity in the view.


But none seem to work. I know in the grand scheme of it all it will need to be a $key, $val instead of the telephone as it will be dynamic, but if I can get it working then I'll have a bit of a chance.

Is there any Laracast videos which go into this in detail? Or can someone help with this.

Many thanks

28 Jan
5 months ago

skoobi left a reply on Looping Through A Json Object?

Hi @mikemacdowell.

Thank you for your reply. I forgot to reword the post. I changed the database to grab the encoded json and add it all like so::

$data = json_encode([
            'type' => 'account',
            'old' => [
                'telephone' => Auth::user()->details->telephone,
                'email' => Auth::user()->email
            ],
            'new' => [
                'telephone' => $request->get('telephone'),
                'email' => $request->get('email')
            ]
        ]);

which produces '{"type":"account","old":{"telephone":"12345678","email":"[email protected]"},"new":{"telephone":"12345678333","email":"[email protected]"}}'

For whatever reason I cannot for the life of me get it to display the correct data.

Many thanks

skoobi started a new conversation Looping Through A Json Object?

Hi., Sorry I don't do much with JSON and am trying to learn/use it more to learn.

I wanted to add a custom activity tracker to a small test project I have that tracks the old and new values from a webform. So if a user updates their phone number it logs the old value and the new one.

The way it works at the moment is that when an user saves their details, It grabs the old data and the new data and saves it to the database under old and new columns::

public function saveActivity($request)
    {
       $data = json_encode([
            'type' => 'account',
            'old' => [
                'telephone' => Auth::user()->details->telephone,
                'email' => Auth::user()->email
            ],
            'new' => [
                'telephone' => $request->get('telephone'),
                'email' => $request->get('email')
            ]
        ]);
        $activity = Helpers::saveUserActivity($data);
    }

this saves the data into the data field along with the authenticated user id.

What I can quite get my head around is displaying it on a blade template.

The issue I think I'm going to get is if theres a different types which I want to filter and there will be different fields depending on the type.

Can someone point me in the right direction with this one.

Many thanks

24 Jan
5 months ago

skoobi left a reply on Validation Issue?

Just checked and im not passing through the public $validator;

So should look like

public $validator;


**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'courier_id' => 'required_if:send_by,4|numeric',
        ];
    }

    /**
    * Overrid Handle a failed validation attempt.
    *
    * @param  \Illuminate\Contracts\Validation\Validator  $validator
    * @return void
    *
    * @throws \Illuminate\Validation\ValidationException
    */
    protected function failedValidation(\Illuminate\Contracts\Validation\Validator $validator)
    {
        $this->validator = $validator;
    }

skoobi left a reply on Validation Issue?

Ah ok. Strange as it works on other validation. Ill have to go back and double check that its the same as the others and not been changed ...

Cheers

skoobi started a new conversation Validation Issue?

Hi. Im getting an odd issue where I cannot validate inputs.

When trying to add a required_if attribute to the courier_id field it comes back ass a pass.

The strange thing is, if I make it a required field it also passes.

Controller (for testing)::

public function store(StoreDespatchRequest $request, User $user)
{
        if (isset($request->validator) && $request->validator->fails()) {
            Toaster::danger("It looks like there is a problem!!");
            return redirect()->back()->withErrors($validator)->withInput();
        }
        return $request->all();
}

StoreDespatchRequest::

**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'courier_id' => 'required_if:send_by,4|numeric',
        ];
    }

    /**
    * Overrid Handle a failed validation attempt.
    *
    * @param  \Illuminate\Contracts\Validation\Validator  $validator
    * @return void
    *
    * @throws \Illuminate\Validation\ValidationException
    */
    protected function failedValidation(\Illuminate\Contracts\Validation\Validator $validator)
    {
        $this->validator = $validator;
    }

View::

<div class="row despatchSection">
            <label class="inlinelabel">SEND BY</label>
            <select class="despatchSelect" name="send_by" id="send_by">
                @foreach($forwarding_by as $sent_by)
                <option value="{{ $sent_by->id }}" @if($customer->forwarding->forward_by_id == $sent_by->forward_by_id) selected @endif>{{ $sent_by->title }}</option>
                @endforeach
            </select>
        </div>

        <div class="row despatchSection" name="courier">
            <label class="inlinelabel">COURIER</label>
            <select class="despatchSelect" name="courier_id" id="courier">
                <option value=""></option>
                @foreach($delivers_by as $deliver_by)
                <option value="{{ $deliver_by->id }}">{{ $deliver_by->title }}</option>
                @endforeach
            </select>
        </div>

Response::

{
_token: "uXeep3ih8wZeifdq4NpB51syruMZpYjq3EySnPy8",
letters_out: "2",
large_letters_out: "0",
parcels_out: "0",
send_by: "4",
courier_id: null,
tracking_ref: null,
postage_cost: "1",
total: "3.80"
}

Any ideas on why its not picking up null and passing the request

09 Jan
6 months 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
6 months 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
6 months 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
6 months 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
6 months 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
6 months 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
6 months 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
6 months 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
6 months 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 &#039;name&#039; 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?