jeudi 1 décembre 2016

Laravel elixir combine some file, but minify just some of them

Iv've got three files: a.min.js, b.min.js and c.js

I would like to minify c.js, and then combine a + b + c into a unique file using laravel elixir. Is it possible? Now I'm using this script:

elixir(mix => {
    mix.sass('app.scss')
            .webpack('app.js')
            .combine([
                'resources/assets/js/plugins/a.min.js',
                'resources/assets/js/plugins/b.min.js',
                'resources/assets/js/plugins/c.js'
            ], 'public/js/plugins/xxx.js');
});

But obviously c.js is not minified.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2fJtP8B
via IFTTT

Request not found error in laravel controller

I have Laravel version 5.3 and i created a file createArticleRequest.php under the request folder , which looks like below:

<?php namespace App\Http\Requests;

use App\Http\Requests\Request;

class CreateArticleRequest extends Request {


    public function authorize() {
        return true;
    }

    public function rules() {
        return  [
            'title' => 'required|min:3',
            'body'  => 'required',
            'published_at'  => 'required|date',
        ]
    }


} 

?> 

In My articles controller i have the following method:

public function store(CreateArticleRequest $request) {
        // $input = Request::all();
        Article::create($request->all());
        return redirect('articles');
}

But when i fill the form in my view and click on submit i get an error like so:

ReflectionException in Route.php line 286:
Class App\Http\Controllers\CreateArticleRequest does not exist

Why am i getting this error ??

I believe my articles Controller and my createArticlesRequest are in the same namespace so why am i getthing this error?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2gbLdPP
via IFTTT

Why is my variable undefined in my Laravel Blade when using it, but not while dumping it?

I define a Custom Form Component and a Custom Blade

Form component in a serviceprovider's boot() method

Form::component('TextInput', 'partials.inputs.text', [
        'id' => 'id-placeholder',
        'label' => 'label placeholder',
        'required' => false,
        'attr' => []
    ]);

Blade (resources\views\partials\inputs\text.blade.php)

 //"first_name"
<div class="input-field">
    <input id="" type="text"
    @if (array_key_exists('value', $attr)) value="" @endif
    @if ($required) required @endif>
    <label for="" >
        
    </label>
</div>

But with the data dump function I get the error:

Undefined variable: id (View: \resources\views\partials\inputs\text.blade.php) (View: \resources\views\partials\inputs\text.blade.php)

I call the form component from another blade with:

 

Why is this error happening, even when 2 lines above it outputs the variable?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2gpLzVN
via IFTTT

Laravel 5.3 Eloquent foreign key constraint fails 1452

So others who have posted a similar issue have had responses saying set the $fillable array to contain the foreign key column. I have added brand_id to my fillable array but it makes no difference.

The migration adds a brand_id column to the fabrics table (each fabric has one brand):

Schema::table('es_fabrics', function ($table) {
    $table->integer('brand_id')->unsigned();
    $table->foreign('brand_id')->references('brand_id')->on('es_brands');
});

The column is created but when the migration comes to making the foreign key constraint I get the following error:

[Illuminate\Database\QueryException]
  SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`es-app`.`#sql-33d4_9e`, CONSTRAINT `es_fa
  brics_brand_id_foreign` FOREIGN KEY (`brand_id`) REFERENCES `es_brands` (`brand_id`)) (SQL: alter table `es_fabrics` add constraint `es_fabrics_brand_id_foreign` foreig
  n key (`brand_id`) references `es_brands` (`brand_id`))



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2fILflS
via IFTTT

Undefined variable in view laravel

I have this code here which is listing all items from one user, user and item are two differents model and they have relationship with their primary keys.

@foreach($user->items as $item)
    <p class="heading">
         <a href=""></a>
     </p>
@endforeach

My question is how to send that item_id with post request to controller, because when I write like this for example <form class="form-horizontal" method="post" action="" role="form" enctype="multipart/form-data"> it gives me that $item variable is not defined.

Any ideas how to send that item_id?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2fP80j6
via IFTTT

Laravel Send Mail fails

I installed laravel on my localhost server, i already configured my .env email setting.

This is my .env email setting

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=pinblackwell@gmail.com
MAIL_PASSWORD=blackwell123
MAIL_ENCRYPTION=tls

This is the error i get.

ErrorException in StreamBuffer.php line 95:
stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

Is there anyone know how to solve this problem? Appreciate that if you could guide me how to solve this.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2gJWw54
via IFTTT

laravel 5 won't delete files from storage section

when I try to delete specific file trough my controller i get an error

Sorry, the page you are looking for could not be found. NotFoundHttpException

this is my controller

public function destroyFile($file_name)
{
    $file = storage_path('documents').'/'.$file_name;
    Storage::delete($file);
    return redirect('/documents');
}

route

  Route::delete('documents/{file}','FilesController@destroyFile');

and view

    {!! Form::open(['method' => 'DELETE', 'action' =>     ['FilesController@destroyFile', $file->name] ]) !!}
                            {!! Form::hidden('_method', 'DELETE') !!}
                            {!! Form::token() !!}
                            {!! Form::submit(trans('buttons.del-cat'),['class'=>'btn btn-danger user-delete push-right']) !!}
                            {!! Form::close() !!}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2gYqcMi
via IFTTT