bastman69

bastman69

Member Since 3 Years Ago

Experience Points
73,140
Total
Experience

1,860 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
686
Lessons
Completed
Best Reply Awards
14
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 15
73,140 XP
Sep
20
2 years ago
Activity icon

Replied to Filtering Your Repository

Watch episode 15 on lets build a forum series. It is a video where jeffrey implements an abstract filters class. I think is one efficient approach which can give you an idea.

Sep
18
2 years ago
Activity icon

Replied to PHP Email Verification

https://laracasts.com/lessons/email-verification-in-laravel 

found it. it is written on laravel 5.1 but you will an idea on how you can do it.

Activity icon

Replied to PHP Email Verification

check the tutorials if i am not wrong jeffrey has a screencast.

Jul
12
2 years ago
Activity icon

Replied to Laravel Mix Can't Find App.js

This is a developer life though.. keep researching.. take care.

Activity icon

Replied to Needs To Update Request Base URL

open your .env file and check that APP_URL is on the test.net the redirection should be handled by your server (test.com parked domain that redirects to test.net. cpanel stuff). your application should be agnostic and work from the .net

Activity icon

Replied to Increment A Variable In An Array Without Setting It First

Your collections is still there. As long as you dont transform it or map it to something else.

you can use the sum() to find the number of all invoices without iteration.

and you can try sum inside the loop for the invoice items.

with that way you will avoid the loop inside the loop. looping invoices and then looping the items in the invoice.

Activity icon

Replied to Increment A Variable In An Array Without Setting It First

Logically this

$sales = $this->cart->monthSummary(request());

returns an eloquent collection and your conditional should be

if($sales->count() > 0)

Next for the iterations i think you should take a look to the collection helpers https://laravel.com/docs/5.4/collections#method-sum

Jul
09
2 years ago
Activity icon

Replied to Database Migrations Set Limits

Can you be more verbose please?

Do you mean decimal ? or accepted range of values?

Jul
03
2 years ago
Activity icon

Replied to Redirect To Another URL When Fails To Connect O Database

Maybe you can make it with .htaccess. If Laravel fails to connect will throw an exception with a status code error(500 if i am not wrong). if you catch the error in the .htaccess (public directory)you can redirect the user to another domain. example code below.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Redirect 500  http://your-new-url
</IfModule>

If you need to stay on the domain you can create a custom error page. https://laravel.com/docs/5.4/errors#custom-http-error-pages

Activity icon

Replied to Order By Field

Laravel fortunately give you the flexibility to do the same thing with different ways.

  1. You Can Do it in a method in your model query
$items = Item::sortBy('price', 'desc')->get()
  1. You can do it in the controller.
  2. You can do it in your view in the foreach loop
@foreach($items->sortByDesc('price') as $item)
code here
@endforeach 

And many more. You should always be Advised from the Original Documentation. It contains everything. https://laravel.com/docs/5.4/collections#method-sort

Why don't you follow the series Laravel 5.4 from scratch? to get started.

May
29
2 years ago
Activity icon

Replied to Xdebug On Laragon

I think xDebug is already installed with laragon. you should enable it on php.ini

May
03
2 years ago
Activity icon

Replied to Eager Loading Polymorphic Relationship. Need Help

try

$feeds = \App\Activityfeed::with(['feedable.product', 'feedable.business'])->get();
Apr
20
2 years ago
Activity icon

Replied to Layouts Of My Laravel Is Not Working

I have not figured out why this is happening but i was on a similar situation and that solution worked for me.

Activity icon

Replied to Layouts Of My Laravel Is Not Working

i guess you have placed you css files in the public/css directory.

replace your links like this

<link href=" {{ URL::asset('css/bootstrap.min.css') }}" rel="stylesheet">

give it a try

Activity icon

Replied to Layouts Of My Laravel Is Not Working

#admin.layouts.master

@include ('admin.layouts.top_bar')

@include ('admin.layouts.nav_bar')

@yield('content')

@include('admin.layouts.footer')

#show.blade.php
@extends('admin.layouts.master')

@section('content')
#view content here
@endsection

Try this

Activity icon

Replied to Batch Import Laravel Scout

You must check:

  1. That the user and password compinations exist on the MySQL Server.
  2. Ensure the the Mysql server accepts remote connections if your request comes from an external source.
Activity icon

Replied to Issue With Laravel Dusk

Well i dont see an issue. This is testing. errors, fixing errors, refactoring. I would recommend to delete that file and start by writing a test for your existing codebase.

Activity icon

Replied to Issue With Laravel Dusk

Yes that file i mean. If you want to embed code in your post you can use 3 backticks before and after your code. eg.

class ExampleTest extends DuskTestCase 
{ 
/** * A basic browser test example. * * @return void */ 

   public function testBasicExample() 
   { 
      $this->browse(function (Browser $browser) { 
          $browser->visit('/')
          ->assertSee('Laravel'); 
    }); 
   } 
}
Activity icon

Replied to Issue With Laravel Dusk

Did not see expected text [Laravel] within element [body]. Failed asserting that false is true.

In the tests/Browser folder Dusk has created a sample test which runs and expects to see the word Laravel in your Homepage

Activity icon

Replied to Text Date Validation

Can you provide the form input code ?

Activity icon

Replied to Get PDOException In Connector.php Line 55: Could Not Find Driver Error

  1. check that you database settings are set in the .env file in your root folder.
  2. check that your mysql server is up and running
  3. run php artisan config:clear
  4. php artisan serve

it should work

Activity icon

Replied to Get This Error

Can you be more verbose ? What are you trying to do?

Apr
19
2 years ago
Activity icon

Replied to Facing Difficulties

@Nomanmehrani Sometimes i watch a video 4-5 times in order to clearly understand what is going on. This is not bad and i suggest to do the same. I also suggest to follow the examples in the series you are watching.

"Sir" is not accounted the same in all nationalities. I guess @Nomanmehrani wanted to be formal and thats all.

Apr
13
2 years ago
Activity icon

Replied to Extracting A Repeated Code From Controller

The good practice is that you try to re-factor your code. I don't think there is right or wrong.

The simplest is to be a method in your controller. Yes you can definitely move it to the model. it would be even better if you create a mutator method in your model

function setSlugAttribute($string){
return str_slug($string) . date('Y-m-d') . '-' . uniqid();
}

So you never bother again. https://laravel.com/docs/5.4/eloquent-mutators for your reference.

Activity icon

Replied to Mapping Of Database

Although you can use your DB as is if you dont care about migrations at the moment. Enter your Db details in your .env file. create Models and start quering.

Activity icon

Replied to Laravel Complains For Missing Non-nullable Value, But It Is There

Have you setup any relations in your model? The problem is not on the code you provided.

The problem occurs from this call Sample::insert($samples);

Activity icon

Replied to Laravel Complains For Missing Non-nullable Value, But It Is There

Integrity constraint violation: 19 NOT NULL constraint failed: samples.supplier_id

The Mysql message means that you try to save a supplier that dont exist so it complaints because it considers it as null.

As i can understand foreign keys exist in your table structure as is right now. If you dont have then you should refresh your migrations.

Apr
12
2 years ago
Activity icon

Replied to Laravel Complains For Missing Non-nullable Value, But It Is There

Do you have a Supplier with id 2 in your suppliers table?

Activity icon

Replied to Am I Just Stupid?

Think Big but start small. The truth is that Laravel gives you the flexibility to do the same thing with different ways. eg.

to retrieve a record from the db

DB::table('users')->find(1);
\App\User::find(1);

I am sure that more ways exist in the framework.

I suggest to follow the PHP Practitioner Course. You will have the opportunity to prepare yourself for laravel. I think this course is the perfect transition.

Activity icon

Replied to Dusk On Centos

Check this out. hope that helps. https://github.com/laravel/dusk/issues/10

Activity icon

Replied to Blank Page Laravel

Avast Complaints for the link you provided...

Activity icon

Replied to I Would Like To Know Your Opinion

You have come in the right place for learning laravel. I thing that the proper way is to follow the order that is suggested from jeffrey. From the skills Menu select PHP and start there. this is my suggestion.

For example must watch are the following :
The PHP Practioner
Object Oriented Bootcamp
Simple Rules for Simpler Code
Code Catas in PHP
Design Patterns in PHP
Solid Principles in PHP
Activity icon

Replied to Eloquent Relationships And MySQL Tables Relationships.

I guess that when creating your migration files you define the relationship by adding eg.

$table->integer('rank_id')->unsigned();

On mySql server this is just a field but enough for laravel to do its magic.

Laravel of course offers the ability to enforce referential integrity

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

If you add foreign keys in your migration files then you will see the connections in your Entity Diagram.

Take a look:

Foreign Key Constraints https://laravel.com/docs/5.4/migrations#generating-migrations

Activity icon

Replied to Unable To Install

Before switch to mac i was using https://laragon.org/ as development environment on windows. check it out. its free.

Apr
11
2 years ago
Activity icon

Replied to Testing Database 5.4

While testing, errors are not bad. Try to fix them. new test, new errors, new fixing code, code refactoring, new errors etc. its normal situation.

Activity icon

Replied to Testing Database 5.4

The videos are one year old and for sure with and older version of laravel. Anyway leave this project as is and create a new one update your phpunit.xml as above, use the DatabaseTransactions trait and hopefullly it will work.

Laravel documentation is also reach of examples. https://laravel.com/docs/5.4/testing

Activity icon

Replied to Testing Database 5.4

if your tests needs are to migrate the database then you must use the DatabaseMigrations trait.

use DatabaseMigrations;

In my setup i dont use a .env.testing file. i have my developement db setup (mysql) and in my phpunit xml i have the test db details as per my previous message.

Spend 2 hours and check this series https://laracasts.com/series/phpunit-testing-in-laravel

Activity icon

Replied to Testing Database 5.4

insert those in your phpunit.xml

<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
Activity icon

Replied to LARAVEL 5.3 How To Store Empty DateTime Input To Null Value Instead Of 0000:00:00 00:00 Value

public function store(Request $request)
    {
        $rules = array(
            'customer_name' => 'required',
            'arriveDateTime' => 'required_without:departDateTime',
            'departDateTime' => 'required_without:arriveDateTime',
        );
        $messages = array(
            'customer_name.required'=>'Name is required',
            'arriveDateTime.required_without'=>'Arrive DateTime required',
            'departDateTime.required_without'=>'Depart DateTime required',
        );
        
        $validator = Validator::make(Input::all(), $rules, $messages);
                    
        if($validator->fails()){
            return back()->withInput()->withErrors($validator);
        } 
        elseif ($validator->passes()){
            $flight = new Flight;

            if($flight->save()){
                $id = $flight->id;
                foreach($request->customer_name as $key => $v){
                    $data = array('flights_id' => $id,
                                'customers_id' => $v,
                                'arriveDateTime' => $request->arriveDateTime !== null ? date('Y-m-d H:i:s', strtotime($request->arriveDateTime)) : null,
                                'departDateTime' => $request->departDateTime !== null ? date('Y-m-d H:i:s', strtotime($request->departDateTime)) : null,
                                'destination' => $request->destination,
                                'remark' => $request->remark,
                    );
                Flightitem::insert($data);
                }
            }
        }
    }

you must refresh your migrations first. And better use Carbon for this

date('Y-m-d H:i:s', strtotime($request->arriveDateTime))
Activity icon

Replied to LARAVEL 5.3 How To Store Empty DateTime Input To Null Value Instead Of 0000:00:00 00:00 Value

public function up()
    {
        Schema::create('flightitems', function (Blueprint $table) {
            $table->increments('id');
            $table->datetime('arriveDateTime')->nullable();
            $table->datetime('departDateTime')->nullable();
            $table->string('destination');
            $table->text('remark')->nullable();
            $table->integer('customers_id')->unsigned();
            $table->foreign('customers_id')->references('id')->on('customers');
            $table->integer('flights_id')->unsigned();
            $table->foreign('flights_id')->references('id')->on('flights');
            $table->timestamps();
        });
    }
Activity icon

Replied to LARAVEL 5.3 How To Store Empty DateTime Input To Null Value Instead Of 0000:00:00 00:00 Value

you can post here.

copy paste your code inside 3 backticks

put your migration file, your view, your controller and your model.

Activity icon

Replied to LARAVEL 5.3 How To Store Empty DateTime Input To Null Value Instead Of 0000:00:00 00:00 Value

Please refer to the documentarion https://laravel.com/docs/5.4/migrations the way that the documentation mentions the null values for a field is as my previous.

propably you have a request object that passed from your view you may use a conditional

$request->arriveDateTime !== null ? mymodel->arriveDateTime = $request->arriveDateTime : mymodel->arriveDateTime=null;
Activity icon

Replied to LARAVEL 5.3 How To Store Empty DateTime Input To Null Value Instead Of 0000:00:00 00:00 Value

First you must update the field in the database to accept null values then you can set the field to null while saving.

eg. in your migration file

$table->string('email')->nullable();

and in your controller or model check if the users has completed a value or set to null

Apr
10
2 years ago
Activity icon

Replied to Help Please Simple SQL Laravel

You should experiment with DB::raw or you may create a view in your mysql server and call the view.

DB::select( DB::raw("SELECT * FROM some_table WHERE some_col = '$someVariable'") );