Including SVG contents in Laravel 5 Blade template

Similar to the accepted answer but a bit cleaner (imo). Use the laravel directive to extend blade, like so (in your App Service Provider, as outlined here): \Blade::directive(‘svg’, function($arguments) { // Funky madness to accept multiple arguments into the directive list($path, $class) = array_pad(explode(‘,’, trim($arguments, “() “)), 2, ”); $path = trim($path, “‘ “); $class … Read more

Class App/Http/Controllers/View Not Found error

The problem is not the actual view but the class View. You see when you just reference a class like View::make(‘tickets.bus.index’) PHP searches for the class in your current namespace. In this case that’s App\Http\Controllers. However the View class obviously doesn’t exists in your namespace for controllers but rather in the Laravel framework namespace. It … Read more

Laravel 5.6 – Pass additional parameters to API Resource?

The following approach worked for me: UserResource class UserResource extends Resource{ protected $foo; public function foo($value){ $this->foo = $value; return $this; } public function toArray($request){ return [ ‘id’ => $this->id, ‘name’ => $this->name, ‘foo’ => $this->foo, ]; } public static function collection($resource){ return new UserResourceCollection($resource); } } UserCollection class UserResourceCollection extends ResourceCollection{ protected $foo; public … Read more

Laravel parse error: syntax error, unexpected T_CLASS, expecting T_STRING or T_VARIABLE

Laravel 5.1 uses the ::class property to get string representations of a fully qualified classname. The error you’re seeing is caused by this line $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); This language feature has been introduced in PHP 5.5 which is a requirement of Laravel 5.1. Your installed PHP version is probably older than 5.5. Try to update … Read more

error creating migration in laravel: ‘failed to open stream’

I get this error on regular basis, here are some things that might help: php artisan cache:clear or delete the cache manually in the bootstrap directory (it is responsible for the route and services cache. also these methods could help: composer dump-autoload -o composer update Composer dump-autoload regenerates the list of all classes that need … Read more

How to define and use JSON data type in Eloquent?

In your migrations you can do something like: $table->json(‘field_name’); And in your model you add the field to the $casts property to instruct Eloquent to deserialize it from JSON into a PHP array: class SomeModel extends Model { protected $casts = [ ‘field_name’ => ‘array’ ]; } Source: https://laravel.com/docs/5.1/eloquent-mutators#attribute-casting Note: This is also relevant answer … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)