dimanche 26 février 2017

Laravel: Layouts.master not found

I built the demosite in Laravel, but I got the following error:

ErrorException in FileViewFinder.php line 137: View [layouts.master] not found.(View: /var/www/html/project/laravel/laravel/resources/views/page.blade.php)

The master.blade.php is next to the page.blade.php, both are in resources/views

master.blade.php

<html>
    <head>
        <title>@yield('title')</title>
    </head>
    <body>
        @section('sidebar')
        This is the master sidebar.
        @show
        <div class="container">
        @section('content')
        </div>
    </body>
</html>

page.blade.php

@extends('layouts.master')
@yield('title', 'Page Title')
@section('sidebar')
@parent
<p>This is appended to the master sidebar.</p>
@endsection
@section('content')
<h2></h2>
<p>This is my body content.</p>
@endsection

What goes wrong? I working from this tutorial.



via Chebli Mohamed

How to recording the user's device in laravel

how to add data device (tablet, mobile, desktop) if users access to one of the devices when logged on, then the data was recorded.

i use packages jenssegers/agent

table device having column: device_name, date

i try, but can't record in table

this my code in LoginController.php

   public function check(){
      $agent = new Agent();
      $dt = Carbon::now();

      if ( $agent->isDesktop() == true )
      {
        DB::table('device')->insert([
           ['device_name' => 'desktop', 'tgl' => $dt->toDateString()],
       ]);
      }

      elseif ($agent->isTablet() == true) {
        DB::table('device')->insert([
           ['device_name' =>'tablet', 'tgl' => $dt->toDateString()],
       ]);
      }

      elseif ($agent->isMobile() == true) {
        DB::table('device')->insert([
           ['device_name' => 'mobile', 'tgl' => $dt->toDateString()],
       ]);
     }

    }

please help me, thank you very much...



via Chebli Mohamed

Failed to authenticate on SMTP server with username "xxxxxxxxxxxxxxxx" using 2 possible authenticators

In env file mentioned

MAIL_DRIVER=smtp
MAIL_HOST=email-smtp.us-east-1.amazonaws.com
MAIL_PORT=587
MAIL_USERNAME="AKIAJEMHKHYWE52H4HZA"
MAIL_PASSWORD="AhD1x1VrZzuhkF+I3xcWwNPbxRueVp/3TsPUNUiH/8Ua"
MAIL_ENCRYPTION=

SES_KEY="AKIAIVY5UDDAXQC7DG2A"
SES_SECRET="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"
SES_Region="US East (N. Virginia)"

Unable to send email in laravel by amazon ses ,all the credentials are correct but i keep on getting this error The user credentials are correct but I still receive the following error:

Failed to authenticate on SMTP server with username "email@example.com" using 2 possible authenticators



via Chebli Mohamed

Execution of Laravel Queue listener for undefined time

I'm working on a system that needs run multiple works but the time when this works will be triggered it's undefined. I've implemented a couple of Jobs in order to run this works in background because some of them take up to 20 minutes.

My question is:

  • It is ok to let the queue listener run with a timeout=0? If the answer is no, what is the best practice to resolve this problem?

Thanks for your help.



via Chebli Mohamed

Sass in Laravel 5.4

In Laravel < 5.4 I was able to do the following with elixir to compile all of my sass files in one css file.

mix.sass([
    'file_1.scss',
    'file_2.scss',
    'file_n.scss'
], 'public/css/app.css');

In Laravel 5.4 this is not working. Is there a chance to do something similar in Laravel 5.4?



via Chebli Mohamed

Best practice for updating user 'rank' using a cron job

In my site I have users who can create posts, make a description, upload profile picture, provide email address etc

I want to give users a 'score' or 'rank' depending upon how much they have updated their account. For example, providing a profile pic will be +10 points, a long description will be +5 points, making a post will be +2 points etc

I was going to have a user model method that when executed updates their score and adds it to a column in the users table.

It was suggested to me that I use a cron job for this, and update it once a day as opposed to updating every time the user makes a change to their account.

I was wondering what was best practice for this, and where I should store the user's 'score'.



via Chebli Mohamed

Class 'Form' not found (View: /path/to/laravel/resources/views/posts/create.blade.php)

I am trying to use Forms but keep getting this Error.

Class 'Form' not found

and

Class 'Form' not found (View: /path/to/laravel/resources/views/posts/create.blade.php)

my create.blade.php

@section('content')
<div class="row">
  <div class="col-md-8 col-md-offset-2">
    <h1>Новая новость</h1>
    <hr>
      {!! Form::open(['route' => 'posts.store']) !!}
        {!! Form::label('title',"Заголовок:") !!}
        {!! Form::text('title', null, array('class' => 'form-control')) !!}

        {!! Form::label('body', "Текст:") !!}
        {!! Form::textarea('body',null, array('class' => 'form-control')) !!}

        {!! Form::submit('Сохранить', array('class' => 'btn btn-success btn-lg btn-block', 'style' => 'margin-top:10px;')) !!}
      {!! Form::close() !!}
  </div>
</div>
@endsection

I add all needed lines and executed the commands according to the manual @ Laravel Collective

Providers:

Collective\Html\HtmlServiceProvider::class,

Alias:

'Form' => Collective\Html\FormFacade::class, 'Html' => Collective\Html\HtmlFacade::class,



via Chebli Mohamed