kgp43

kgp43

Member Since 3 Years Ago

Experience Points
7,060
Total
Experience

2,940 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
74
Lessons
Completed
Best Reply Awards
0
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 2
7,060 XP
17 Jul
2 months ago

kgp43 started a new conversation Nova, How To Save Product Features In Separate Table?

Hi,

I'm using Nova to add and modify product data.

Currently I have a tables/models for each product type (each type got a lot of features that I need to use), but a user on this forum suggested, that I make one product table, and then added the features in a separate table - I kinda love that idea. Makes other stuff A LOT easier for me.

I'm not sure how to make that work with Nova though. Not sure what "route" to go.

Lets say I have the following tables:

products
id
name
products_features
id
product_d
property
value

The properties always have the same "names", but the values are of cause different. Each product-type have about 10 features that needs to be saved.

Seems like a simple task, but i'm lost for ideas. How would you handle it?

Hope one of you might be able to point me in the right direction :)

, Kenneth

kgp43 left a reply on Pivot Table For 3 Models?

@tray2 Thats not a bad idea at all.

Going to look into that for an upcoming project. Never tried that before though.

kgp43 left a reply on Pivot Table For 3 Models?

@davidpetrov Thanks, will look into that. Each product (motor or gear) can have many prices from many suppliers.

kgp43 started a new conversation Pivot Table For 3 Models?

Hi,

I got 3 models: motors, gears and suppliers.

I would like to attach purchase-prices to my products (motors and gears) from a supplier. Any suggestions how to do that?

Can i create some kind of pivot table like this?

motor_id (nullable)
gear_id (nullable)
supplier_id

Also, each product (motor or gear) can have many prices from many suppliers.

Then use motor_id or gear_id when needed (will only be one of them)?

I'm kinda lost for ideas here :(

07 Jul
2 months ago

kgp43 left a reply on Nova: Add Value To Database Based On Form Inputs

Ohhh.... this is working:

$event->product->save();

kgp43 left a reply on Nova: Add Value To Database Based On Form Inputs

I got most of it working. Can how log the changes to my "description field", but running into trouble when i try to save it to my database.

$event->save() does not work. Not sure what else to use.

model:

namespace App;

use Illuminate\Database\Eloquent\Model;

use App\Events\NewProduct;

class Product extends Model
{
    
    /**
     * The event map for the model.
     *
     * @var array
     */
    protected $dispatchesEvents = [
        'created' => \App\Events\NewProduct::class,
    ];
    
}

event:

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

use App\Product;

class NewProduct
{
    use Dispatchable, InteractsWithSockets, SerializesModels;
    
    public $product;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct(Product $product)
    {
        $this->product = $product;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new PrivateChannel('channel-name');
    }
}

Listener:

namespace App\Listeners;

use App\Events\NewProduct;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

class ProductDescription
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  NewProduct  $event
     * @return void
     */
    public function handle(NewProduct $event)
    {
        $event->product->description = 'This is a test description';
        //app('log')->info($event->product);
        $event->save();
    }
}

Most of the stuff I have read, they only explain how to output to log. Not sure how to save it to the model though :/

06 Jul
2 months ago

kgp43 left a reply on Nova: Add Value To Database Based On Form Inputs

Thanks! Will look into that :)

05 Jul
2 months ago

kgp43 left a reply on Nova: Add Value To Database Based On Form Inputs

Hmm... I dont think that will work.

I would like to create a default product description, based on selected feaetures from the form. Then be able to edit the product description after creation. So the description is only prefilled upon first creation, then modified in the form after.

This to make some kind of the "standard product description", which can be edited later.

Not sure if that makes sense.

, Kenneth

04 Jul
2 months ago

kgp43 started a new conversation Nova: Add Value To Database Based On Form Inputs

How can I make it, so a cell in my database get a value based on some form input values, that I have submitted in Nova?

Example:

I got 3 input fields that are saved to my database: input1, input2, input3 I then want to automatically add those values to a "description" column in my table (database), value of the column will be "input1 + input2 + input3". So the column is "prefilled" with content submitted by the create form.

Any help would be welcome :)

23 Jun
2 months ago

kgp43 left a reply on Only List Active Resources In Select Menu?

Found the solution I think.

Added this to Nova->Resource.php

public static function relatableBrands(NovaRequest $request, $query)
    {
        return $query->where('active', 1);
    }
22 Jun
2 months ago

kgp43 left a reply on Only List Active Resources In Select Menu?

But filters only apply to the "index" page of the resource, right? Not the create page. My menu is on the create page.

kgp43 left a reply on Only List Active Resources In Select Menu?

I feel so dump, completely lost :(

Do you know where I can read up on that?

I got two resources: Motor and Brand When creating a new Motor resource, then the menu (Select) should only list the active ones.

Nova -> Motor.php

...
    public function fields(Request $request)
    {
        return [
            
            # Brand
            BelongsTo::make('Select a Brand', 'brand', 'App\Nova\Brand'),
            
        ];
    }
...

Motor model:

namespace App;

use Illuminate\Database\Eloquent\Model;

class Motor extends Model
{
    public function Brand()
    {
        return $this->belongsTo('App\Brand');
    }
}

No controllers or routes - Nova handles all that.

kgp43 left a reply on Only List Active Resources In Select Menu?

Thank you very much for the reply. In that file do I add that? Not sure where to add it :(

kgp43 started a new conversation Only List Active Resources In Select Menu?

Hi,

How can I make it so only active resources are listed in my Select menu within Nova? It got menu working etc, but it list all resources and not just the active ones.

I have searched the Nova documentation, but cant find anything about it :(

Any of you know how to filter those or what to search for (terms)? Kinda blank :(

24 Mar
5 months ago

kgp43 left a reply on Problems With Array_sum In Nova?

Found the error. Not a problem with array_sum as expected, the problem was actually json_decode.

Working:

$arr = json_decode($json, true);

kgp43 started a new conversation Problems With Array_sum In Nova?

Hi,

Is there is problem with array_sum in Nova? Getting "Expecting parameter 1 to be an array".

I think this should work, or have I made a mistake?

                Text::make('Costprice', function () {
                    $json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
                    $arr = json_decode($json);
                    return array_sum($arr);
                })->hideFromIndex(),

Should return 15

kgp43 left a reply on Only Update Db Field If Input Is Set

@TRAY2 - Thanks for the reply.

Going to look into required_if, thanks :)

kgp43 left a reply on Only Update Db Field If Input Is Set

@ARTCORE - "sometimes" works perfect. Had no idea that was possible.

Thanks :)

    public function update(Request $request, $id)
    {
        
        $validator = Validator::make($request->all(), [
            'inlet_id' => 'sometimes|numeric',
            'outlet_id' => 'sometimes|numeric',
        ]);
        
        if ($validator->fails()) {
            notify()->error('Error');
            return back();
        }
        
        $conf = Configurator::find($id);
        
        # Check if Inlet ID is set
        if(!empty($request->get('inlet_id'))) {
            $conf->inlet_id = $request->get('inlet_id');
        }
        
        # Check if Outlet ID is set
        if(!empty($request->get('outlet_id'))) {
            $conf->outlet_id = $request->get('outlet_id');
        }
        
        $conf->save();
        
        notify()->success('Change saved');
        return back();
    }

kgp43 started a new conversation Only Update Db Field If Input Is Set

Hi,

I have this update:

    public function update(Request $request, $id)
    {
        
        $validator = Validator::make($request->all(), [
            'inlet_id' => 'required|numeric',
            'outlet_id' => 'required|numeric',
        ]);
        
        if ($validator->fails()) {
            notify()->error('Error');
            return back();
        }
        
        $conf = Configurator::find($id);
        
        # Check if Inlet ID is set
        if(is_numeric($request->get('inlet_id'))) {
            $conf->inlet_id = $request->get('inlet_id');
        }
        
        # Check if Outlet ID is set
        if(is_numeric($request->get('outlet_id'))) {
            $conf->outlet_id = $request->get('outlet_id');
        }
        
        $conf->save();
        
        notify()->success('Change saved');
        return back();
    }

The input is updated from modals, so one at a time. Thats why I got the if statements.

The problem is the validation. It fails, because the input fields are never set at the same time.

Any idea how to fix this?

16 Mar
6 months ago

kgp43 left a reply on How To Restrict/limit Resource Edit Without An Login System?

I made a simple "session compare", it does what I need.

I normally make an auth system for this type of thing, but this page must not require login/signup. Security is not hugely important either, so this will work fine i think.

        $conf = Configurator::findOrFail($id);
        
        if ($conf->session_id === Session::getId()) {
            ....
        } else {
            return redirect('/');
        }
15 Mar
6 months ago

kgp43 left a reply on How To Restrict/limit Resource Edit Without An Login System?

That might be a solution.

Or maybe save the Session ID to the configuration/resource table and match current Session ID with the Session ID saved in the table. If they match, then it must be the author and the system will allow access to edit the resource.

Not sure if there is a smart method do add that, or a more simple way. Laravel have so much stuff built-in, so I was hoping for something already built :)

kgp43 started a new conversation How To Restrict/limit Resource Edit Without An Login System?

Hi,

I do not have a login system enabled at the moment, and need to find a workaround, to limit who can edit a resource. Adding the login system is not an option atm.

As of now, all visitors can change settings of my resource (e.g. /configurator/5/edit). How can I make it, so only the creator can edit the resource? Maybe limit on session, but not sure how to do that. I know it will be impossible for them to edit it, after they close the browser - but that will be okay.

Any suggestions?

17 Feb
7 months ago

kgp43 left a reply on How To Access Functions Within A Model, In A View

Thank you very much guys

kgp43 left a reply on How To Access Functions Within A Model, In A View

Hmm... seems like the function I got does not belong to the model in the first place, since its not used to interact with my database. Models are only used for DB stuff, right?

Maybe I should make a helper.php file and add it to that instead.

kgp43 started a new conversation How To Access Functions Within A Model, In A View

Hi,

How can I access a function within a model? (in a view) I got this small function in my model, and I would like to access it in my view.

namespace App;

use Illuminate\Database\Eloquent\Model;

class Convert extends Model
{
    protected $fillable = [
        'unit_type',
        'unit_num',
    ];
    
    public function pressure() {
        
        # Set base values
        # Base: 1 bar
        $base['bar'] = 1;
        $base['pa'] = 100000;
        $base['mpa'] = 0.1;
        $base['nmm2'] = 0.1;
        $base['psi'] = 14.5038;
        $base['ksi'] = 0.0145037738007;
        
        return $base;
        
    }
}

Added this to my view, but it does not work:

{{ App\Convert::pressure() }}
12 Jan
8 months ago

kgp43 left a reply on Laracasts On Apple TV?

2 years later, still want this soo badly :)

I love watching coding videos on my tv, while coding on my laptop. Easy to pause the video with a click on the remote. Annoying to fumble with the phone to unlock and pause. Something like the Udemy app would be lovely i guess.

Seriously hope to see an Apple TV app someday.

10 Jan
8 months ago

kgp43 left a reply on Alter Table Auto_increment, Syntax Error

@VILFAGO - That worked :D Thanks a lot !

public function up()
{
    Schema::create('configurations', function (Blueprint $table) {
        $table->increments('id');
        $table->string('short_description');
        $table->text('long_description')->nullable();
        $table->text('internal_notes')->nullable();
        $table->string('tags');
        $table->boolean('active')->default(true);
        $table->timestamps();
    });
    
    # For mysql
    #DB::statement("ALTER TABLE configurations AUTO_INCREMENT = 14000");
    
    # For sqlite
    DB::insert('insert into sqlite_sequence (name, seq) values (?, ?)', ['configurations', 14000]);
}

kgp43 left a reply on Alter Table Auto_increment, Syntax Error

@VILFAGO - Getting same result. No errors, but ID still start at 1.

Recreating database.sqlite upon each test, so it's an empty table when I create the first record. Not sure if that is causing the problems, but dont think so.

kgp43 left a reply on Alter Table Auto_increment, Syntax Error

@REALRANDYALLEN - I tried that and it helped, some. No error but the ID still start at 1.

public function up()
{
    Schema::create('configurations', function (Blueprint $table) {
        $table->increments('id');
        $table->string('short_description');
        $table->text('long_description')->nullable();
        $table->text('internal_notes')->nullable();
        $table->string('tags');
        $table->boolean('active')->default(true);
        $table->timestamps();
    });
    
    # For sqlite
    DB::statement("UPDATE SQLITE_SEQUENCE SET seq = 14000 WHERE name = 'configurations'");
}

Think the syntax looks okay, at least according to that topic. I also found this one, same solution: https://stackoverflow.com/a/27159763/825793

kgp43 left a reply on Alter Table Auto_increment, Syntax Error

Getting same error after removing ; Deleted the database.sqlite file before running the migration, so the database was fresh. Still same error.

public function up()
{
    Schema::create('configurations', function (Blueprint $table) {
        $table->increments('id');
        $table->string('short_description');
        $table->text('long_description')->nullable();
        $table->text('internal_notes')->nullable();
        $table->string('tags');
        $table->boolean('active')->default(true);
        $table->timestamps();
    });
    
    DB::statement("ALTER TABLE configurations AUTO_INCREMENT = 14000");
}

Error:

SQLSTATE[HY000]: General error: 1 near "AUTO_INCREMENT": syntax error (SQL: ALTER TABLE configurations AUTO_INCREMENT = 14000) {"exception":"[object] (Illuminate\Database\QueryException(code: HY000): SQLSTATE[HY000]: General error: 1 near \"AUTO_INCREMENT\": syntax error (SQL: ALTER TABLE configurations AUTO_INCREMENT = 14000) at /home/ec2-user/environment/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, PDOException(code: HY000): SQLSTATE[HY000]: General error: 1 near \"AUTO_INCREMENT\": syntax error at /home/ec2-user/environment/vendor/laravel/framework/src/Illuminate/Database/Connection.php:452)

The database is created, but the auto increment is not adjusted to 14000. I can add records to the table, but starting at 1

kgp43 started a new conversation Alter Table Auto_increment, Syntax Error

I'm trying to make my ID increment start at 14000, but getting an error - not sure why.

public function up()
    {
        Schema::create('configurations', function (Blueprint $table) {
            $table->increments('id');
            $table->string('short_description');
            $table->text('long_description')->nullable();
            $table->text('internal_notes')->nullable();
            $table->string('tags');
            $table->boolean('active')->default(true);
            $table->timestamps();
        });
        
        DB::statement("ALTER TABLE configurations AUTO_INCREMENT = 14000;");
    }

I'm getting this error on a fresh sqlite database:

SQLSTATE[HY000]: General error: 1 near "AUTO_INCREMENT": syntax error (SQL: ALTER TABLE configurations AUTO_INCREMENT = 14000;) {"exception":"[object] (Illuminate\Database\QueryException(code: HY000): SQLSTATE[HY000]: General error: 1 near \"AUTO_INCREMENT\": syntax error (SQL: ALTER TABLE configurations AUTO_INCREMENT = 14000;) at /home/ec2-user/environment/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, PDOException(code: HY000): SQLSTATE[HY000]: General error: 1 near \"AUTO_INCREMENT\": syntax error at /home/ec2-user/environment/vendor/laravel/framework/src/Illuminate/Database/Connection.php:452)

It say syntax error, but all looks fine to me.

I searched a lot on Google and all guides told me, that the statement above is the correct way to do it. But why do I get this error then?

Hope one of you might be able to help me :)

, Kenneth

09 Jan
8 months ago

kgp43 left a reply on Class 'App\Nova\' Not Found

Thanks for the reply, I will rename the model as soon my head stop spinning :)

kgp43 started a new conversation Class 'App\Nova\' Not Found

I got this weird problem in Nova and I can't find my error - used a couple of hours trying to find the problem - no success :(

Hope one of you might be able to point me in the right direction.

This is the error I receive:

Class 'App\Nova\' not found {"userId":1,"email":"........","exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Class 'App\Nova\' not found at /home/ec2-user/environment/vendor/laravel/nova/src/Fields/BelongsTo.php:108)

I can add records to the "child-resource" just fine, but I get the error when I tried to Attach the record to the "main-resource" using BelongsTo. I got like 10 other BelongsTo on the same resource, and they all works fine, expect the last one (of cause).

Got this in my "main" model:

public function S()
{
    return $this->belongsTo('App\S');
}

Where "S" is the name of the "child-model". Got a "S_id" field in my migration.

I can add records to the "child-resource" just fine.

Got this in my "S" nova resource:

BelongsTo::make('S', 'S')
    ->hideFromIndex(),

I'm so confused, specially when the rest works just fine.

18 Oct
11 months ago

kgp43 left a reply on How To Flash Toastr Error Message If Validation Fails When Using FormRequest?

Directly in the controller? Like so:

public function update(UpdateUser $request)
{
    $user = Auth::user();

    $user->name = $request->input('name');
    $user->email = $request->input('email');
    $user->phone = $request->input('phone');
    
    $user->save();
  
    Toastr::success('Changes saved', 'Success');
  
    return back();
  
}
05 Dec
1 year ago

kgp43 left a reply on If Statement Within Form Input Value

The PHP solution will fix it nicely I think :) Thanks for the help.

kgp43 started a new conversation If Statement Within Form Input Value

Hi,

How should I hand this? (see code below). No value is being displayed, i guess because the if statement is within the " ".

<input type="text" class="form-control" value="
@if($product->salesprice > 0)
    {{ round((($product->salesprice - (($price->amount*7.5)+($price->shipment_cost/$price->purchase_num)))/$product->salesprice)*100) }}
@endif
" disabled>
03 Dec
1 year ago

kgp43 left a reply on How To Just Update One "cell" In My Table Without Getting Fields_required?

Hmm... "sometimes" does not work. The salesprice now update fine, but it blank all other results for the record.

The reason for this is my controller, not sure how to fix it. It set to current values, which is blank - since its not a part of the form I use when updating the salesprice.

public function update(UpdateProduct $request, $id)
    {

        $product = Product::findOrFail($id);
        
        $product->category              = $request->input('category');
        $product->part_number           = $request->input('part_number');
        $product->productname           = $request->input('productname');
        $product->internal_notes        = $request->input('internal_notes');
        $product->description           = $request->input('description');
        $product->salesprice            = $request->input('salesprice');
        
        $product->save();
        
        Toastr::success('Ændringer gemt', 'Handling udført');

        return redirect()->route('product.show', $id);
    }
public function rules()
    {
        
        return [
            'category'               => 'sometimes|required|max:255',
            'part_number'            => 'sometimes|required|max:20|unique:products',
            'productname'            => 'sometimes|required|max:255',
            'description'            => '',
            'internal_notes'         => '',
            'salesprice'             => '',
        ];
        
    }
<form class="form-inline" method="POST" action="{{ route('product.update', $product->id) }}">

    {{ method_field('PATCH') }}
    {{ csrf_field() }}
    
    <div class="form-group">
        <div class="input-group">
            <div class="input-group-addon">Salgspris</div>
            <input type="text" class="form-control" name="salesprice" placeholder="Excl. moms" value="{{ $product->salesprice }}">
            <div class="input-group-addon">DKK</div>
        </div>
    </div>
    <button type="submit" class="btn btn-primary">Ret</button>
    
</form>

kgp43 left a reply on How To Just Update One "cell" In My Table Without Getting Fields_required?

Ahhh.... i think "sometimes" will fit perfectly :D Thanks !

kgp43 started a new conversation How To Just Update One "cell" In My Table Without Getting Fields_required?

Hi,

I hope one of you might be able to help me with a problem. How can I update just one "cell" in my database-table?

I have tried to use the update method in my controller, but getting fields_required errors for the other ... stuff - the values I don't wanna update.

I try to update the "salesprice" in my ProductController:

public function update(UpdateProduct $request, $id)
    {

        $product = Product::findOrFail($id);
        
        $product->category              = $request->input('category');
        $product->part_number           = $request->input('part_number');
        $product->productname           = $request->input('productname');
        $product->internal_notes        = $request->input('internal_notes');
        $product->description           = $request->input('description');
        $product->salesprice            = $request->input('salesprice');
        
        $product->save();
        
        Toastr::success('Ændringer gemt', 'Handling udført');

        return redirect()->route('product.show', $id);
    }

My UpdateProduct request:

public function rules()
    {
        
        return [
            'category'               => 'required|max:255',
            'part_number'            => 'required|max:20|unique:products',
            'productname'            => 'required|max:255',
            'description'            => '',
            'internal_notes'         => '',
            'salesprice'             => '',
        ];
        
    }

I get what is happening, or so I think: My submit form only include one input, the "salesprice", that leave the rest (category, part_number and productname) empty, and thats why I receive the error.

I'm not sure how to get around it though.

Hope so get some nice input from you smart people :)

18 Oct
1 year ago

kgp43 left a reply on Same View For Multiple Layouts

Thanks, will look into that :)

kgp43 started a new conversation Same View For Multiple Layouts

Hi,

I'm working on a configurator for a product, it let the user configure some product settings, that is saved into a db table.

I got a public and members area and would like to give access to the configurator view in both areas (public and member).

How can I do that? My view extends just one layout.

In the example below, the view extends the members layout:

@extends('layouts.cp.app')

But I also have a layout to the public area.

I guess the extends will look like this:

@extends('layouts.home.app')

How do you normally handle views, when they are used in different layouts? Do you copy the view and just have two? But then you need to edit two files... i dont like that.

31 Aug
2 years ago

kgp43 left a reply on Parse Error: Syntax Error, Unexpected '?' In ...

Fixed it :)

sudo a2dismod php5
sudo apt-get install libapache2-mod-php7.1
sudo a2enmod php7.1

phpinfo() now show:

PHP Version 7.1.8-2+ubuntu14.04.1+deb.sury.org+4

My complete list to upgrade PHP, just incase someone else needs it:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get purge -y php*
sudo apt-get install -y php7.1 php7.1-cli php7.1-fpm

sudo a2dismod php5
sudo apt-get install libapache2-mod-php7.1
sudo a2enmod php7.1

kgp43 left a reply on Parse Error: Syntax Error, Unexpected '?' In ...

I did the following:

kgp43:~/workspace (master) $ sudo a2dismod php5.6
kgp43:~/workspace (master) $ sudo a2enmod php7.1
ERROR: Module php7.1 does not exist!

tried with 7.1.8 as well, but same result. php -v show 7.1.8 as installed

kgp43 left a reply on Parse Error: Syntax Error, Unexpected '?' In ...

I can't do that, receive same error :(

In routes/web.php:

Route::get('/phpinfo', function(){
    phpinfo();
});

Update: Added a phpinfo.php file to my public directory, that fixed it :p

Seems i'm running 5.5, even after installing 7.1 Why is that and how can I fix it?

PHP Version 5.5.9-1ubuntu4.22

kgp43 started a new conversation Parse Error: Syntax Error, Unexpected '?' In ...

Hi,

I receive this error after upgrading to 5.5:

Parse error: syntax error, unexpected '?' in /home/ubuntu/workspace/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 233

I have read that the error is caused by not running PHP 7. I'm already running PHP 7.1:

kgp43:~/workspace (master) $ php -v
PHP 7.1.8-2+ubuntu14.04.1+deb.sury.org+4 (cli) (built: Aug  4 2017 14:30:23) ( NTS )

What can cause this error? I cloned my old github.

Parse error: syntax error, unexpected '?' in /home/ubuntu/workspace/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 233


#   Time    Memory  Function    Location
1   0.0017  238968  {main}( )   .../index.php:0
2   0.0018  239632  require( '/home/ubuntu/workspace/bootstrap/autoload.php' )  .../index.php:22
3   0.0019  240296  require( '/home/ubuntu/workspace/vendor/autoload.php' ) .../autoload.php:17
4   0.0024  243808  ComposerAutoloaderInitf3abce778c71633dde0db141ebca9384::getLoader( )    .../autoload.php:7
5   0.0234  1147768 composerRequiref3abce778c71633dde0db141ebca9384( )  .../autoload_real.php:56
27 Aug
2 years ago

kgp43 left a reply on Problems With Bootstrap

Think i had an error in my webpack.mix.js file:

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

mix.styles([
        'node_modules/metismenu/dist/metisMenu.min.css'
    ], 'public/css/vendor.css', './');
  
mix.scripts([
        'node_modules/metismenu/dist/metisMenu.min.js',
        'resources/assets/js/app.js'
    ], 'public/js/app.js', './');

if (mix.inProduction()) {
    mix.version();
}

I tried to combine all my js into a single file (app.js), but it did it work - or so it seems.

This include jquery and bootstrap:

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

mix.styles([
        'node_modules/metismenu/dist/metisMenu.min.css'
    ], 'public/css/vendor.css', './');
    
mix.scripts([
        'node_modules/metismenu/dist/metisMenu.min.js'
    ], 'public/js/vendor.js', './');

// Put version on css and js, but only when in production
if (mix.inProduction()) {
    mix.version();
}

kgp43 left a reply on Problems With Bootstrap

No bootstrap file in the same directory as the app.js file. bootstrap-sass folder exists in node_modules folder.

Have been running:

npm install

package.json:

{
  "private": true,
  "scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch-poll": "npm run watch -- --watch-poll",
    "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "prod": "npm run production",
    "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "devDependencies": {
    "axios": "^0.16.2",
    "bootstrap-sass": "^3.3.7",
    "cross-env": "^5.0.1",
    "jquery": "^3.1.1",
    "laravel-mix": "^1.0",
    "lodash": "^4.17.4",
    "vue": "^2.1.10"
  },
  "dependencies": {
    "font-awesome": "^4.7.0",
    "metismenu": "^2.7.0"
  }
}

Do i still have to install bootstrap using npm? I thought that was already included by default?

26 Aug
2 years ago

kgp43 left a reply on Problems With Bootstrap

That did not work either. Think it need to include the entire folder - no ./bootstrap.js file exists.

ressources/assets/js/app.js:

/**
 * First we will load all of this project's JavaScript dependencies which
 * includes Vue and other libraries. It is a great starting point when
 * building robust, powerful web applications using Vue and Laravel.
 */

//require('./bootstrap');
require('./bootstrap.js')

window.Vue = require('vue');

/**
 * Next, we will create a fresh Vue application instance and attach it to
 * the page. Then, you may begin adding components to this application
 * or customize the JavaScript scaffolding to fit your unique needs.
 */

Vue.component('example', require('./components/Example.vue'));

const app = new Vue({
    el: '#app'
});