lundi 1 mai 2017

Why should Client Creadentials be associated with a user in Laravel Passport?

I want to use Client Credentials to authenticate client applications to access the API.

My problem is with creating client credentials. Using php artisan passport:client requires me to enter a user_id to associate the client to that user. I don't get it. Why the client application has to be associated to a user?! Or Is there another way?

passport:client command only supports creating Password Grant Clients and Personal Grant Client. I don't think that any of them is what I need.

What I really need is to create client credentials that will only be used by the client application so authorize itself to access some APIs. How to do that?



via Chebli Mohamed

laravel using a primary key in another table as input in another table

I have two tables Vehicles table and applications table, I need when a user makes an application, the vehicle_id is automatically inserted into the applications table so that I can track the vehicle the user has applied for... I have created the relationship between the two tables as follows:

In my application model

 
 public function vehicle(){
    return $this->belongsTo('Martin\Models\Vehicle');
  }

In my Vehicle model

public function application(){

return  $this->hasMany('Martin\Models\Application');
}

my migrations for vehicle applications where I want the vehicle_id inserted are as follows:

  public function up()
    {
      Schema::create('applications', function (Blueprint $table) {
          $table->increments('id');
          $table->integer('user_id')->unsigned()->nullable();
          $table->integer('admin_id')->unsigned()->nullable();
          $table->integer('vehicle_id')->unsigned()->nullable();
          $table->integer('application_id')->unsigned()->nullable();
          $table->string('acronym');
          $table->string('destination');
          $table->integer('Number_of_days_hired');
          $table->string('vehicle_registration_number');
          $table->timestamp('departure_date_and_time');
          $table->boolean('approved')->unsigned()->nullable();
          $table->timestamp("created_at")->useCurrent();
          $table->timestamp("updated_at")->useCurrent();
          $table->foreign('user_id')
          ->references('id')
          ->on('users')
          ->onDelete('cascade');
          $table->foreign('admin_id')
          ->references('id')
          ->on('admins')
          ->onDelete('cascade');
          });
          $table->foreign('vehicle_id')
          ->references('id')
          ->on('vehicles')
          ->onDelete('cascade');
          });
    }

how do I get the values into the vehicle_id column?

Application::create([
            'user_id'=>Auth::user()->id,
                                                'vehicle_id'=>,
            'acronym'=>$request->input('acronym'),
            'destination'=>$request->input('destination'),


via Chebli Mohamed

How do you enable SASS in Laravel 5.4?

I`ve looked at the official Laravel document and some other websites but I am not entirely sure how to enable SASS in Laravel.



via Chebli Mohamed

404 Not Found, but route exist in Laravel 5.4

I'm using PhpStorm. I can run and open the index.php, but when I want to press submit button (post sign in), its display 404 not found.

Web server Apache 2.4 running on Windows 10.

This is my home

index.php

This is my route

web.php



via Chebli Mohamed

Showing an overview of the weekly hour registrations in laravel

Fellow coders,

I am having trouble with a project I have to realise for my internship company. I have an hourregistration system in which colleagues can fill in their worked hours in relation to the project - task. What I have to do now is to collect the weekly data that has been filled in using the data type date I filled in in the database. Using a dropdown at the top of my page to cycle through various weeks to gain the data of the user that is logged in..

My question is, how am I able to collect the weekly data using a dropdown at the top of my table so my boss can have an overview of the registration filled in by the currently logged in colleague.

I am literally stuck in this part of my project and I would love to receive some help...

It should look something like this

enter image description here



via Chebli Mohamed

Use of undefined constant value - assumed 'value'

Use of undefined constant value - assumed 'value' how i access?

public function idcount($id)
{
     $stats = DB::table('questions')
     ->select( DB::raw("COUNT('id') as value"))
         ->where('user_id',$id)
        ->groupBy('user_id')
        ->get(
        );
        return $stats.value;
}



via Chebli Mohamed

cannot send mail using mailgun

I am using mailgun driver in laravel app and tried to send mail. But it gives me this error

Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required

config/mail.php

'driver' => env('mailgun', 'smtp'),
'from' => [
        'address' => env('MAIL_FROM_ADDRESS', 'arshaikh_17@hotmail.com'),
        'name' => env('MAIL_FROM_NAME', 'Example'),
    ],

.env

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

services.php

'mailgun' => [
        'domain' => env('mydomain.com.pk'),
        'secret' => env('key-********************'),
    ],

What is wrong with my settings and is there anything else you need to check? Please help I have been trying to study laracast for past 2 days but it doesn't send mail.



via Chebli Mohamed