bastman69

bastman69

Member Since 3 Years Ago

Experience Points 73,090
Experience Level 15

1,910 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 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.

20 Sep
1 year ago

bastman69 left a reply on 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 approach.

18 Sep
1 year ago

bastman69 left a reply on 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.

bastman69 left a reply on PHP Email Verification

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

12 Jul
1 year ago

bastman69 left a reply on Laravel Mix Can't Find App.js

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

bastman69 left a reply on 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

bastman69 left a reply on 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.

bastman69 left a reply on 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

09 Jul
1 year ago

bastman69 left a reply on Database Migrations Set Limits

Can you be more verbose please?

Do you mean decimal ? or accepted range of values?

03 Jul
1 year ago

bastman69 left a reply on 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. if you catch the error in the .htaccess you can redirect the user to another domain. Google for htaccess redirection.

bastman69 left a reply on 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

29 May
2 years ago

bastman69 left a reply on Xdebug On Laragon

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

03 May
2 years ago

bastman69 left a reply on Only Getting Last Record From Loop

try

$getDefects=[];
$a_project = Auditproject::where('subid','=',$this->loggedUserSubid)->where('contractorid','=',$this->loggedUser)
                ->where('projectid','=',$request->proj_id)->get();
        
         foreach ($a_project as $a){
            $projectid=$a['projectid'];
            $snagid =$a['snagid'];
            $defectid =$a['defectid'];
            
            $getDefects[]=SnagDefects::where('snag_id','=',$snagid)->where('defect_id','=',$defectid)->get();              
           
}

bastman69 left a reply on Eager Loading Polymorphic Relationship. Need Help

try

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

bastman69 left a reply on 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.

bastman69 left a reply on Unable To Run Npm Run Dev

#ORIGINAL FROM package.json
"scripts": {
    "dev": "node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js 

#UPDATE TO
"dev": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js 

worked for me.

bastman69 left a reply on 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

bastman69 left a reply on 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

bastman69 left a reply on 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 external connections.

bastman69 left a reply on 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.

bastman69 left a reply on 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'); 
    }); 
   } 
}

bastman69 left a reply on 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

bastman69 left a reply on Text Date Validation

Can you provide the form input code ?

bastman69 left a reply on 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

bastman69 left a reply on Get This Error

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

19 Apr
2 years ago

bastman69 left a reply on 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.

13 Apr
2 years ago

bastman69 left a reply on 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.

bastman69 left a reply on 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.

bastman69 left a reply on Data Model With Different Parameters

The difference is that ticushi uses the Laravel Query Builder and you are using Eloquent.

bastman69 left a reply on 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);

bastman69 left a reply on Laravel Complains For Missing Non-nullable Value, But It Is There

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

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

12 Apr
2 years ago

bastman69 left a reply on Laravel Complains For Missing Non-nullable Value, But It Is There

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

bastman69 left a reply on 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.

bastman69 left a reply on Dusk On Centos

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

bastman69 left a reply on Blank Page Laravel

Avast Complaints for the link you provided...

bastman69 left a reply on 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

bastman69 left a reply on 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.

bastman69 left a reply on Unable To Install

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

11 Apr
2 years ago

bastman69 left a reply on 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.

bastman69 left a reply on 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

bastman69 left a reply on 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.

bastman69 left a reply on Testing Database 5.4

insert those in your phpunit.xml

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

bastman69 left a reply on 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

bastman69 left a reply on 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();
        });
    }

bastman69 left a reply on 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