sync () and attach () do not work together?

In my controller first i attach array of ids like this for my additional fields: $property->features()->attach($additional_ids); Then im using sync() because i have checkboxes : $property->features()->sync($features); But problem is when i hav

select some columns of the parent model with Eloquent laravel

I make mode for the name of Content class Content extends Model { /** * The attributes that aren't mass assignable. * * @var array */ protected $guarded = []; /** * Get Images * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public func

Laravel 5 multiple constraint query on impatient load

In my controller I have following code: //Example Data; $date = Carbon::now(); $order = 'name'; // it can be by name, id or created_at; // Approach i try for getting data of user with eager loaded products //1st approach $user = User::with([ 'product

Submitting a form via Ajax and displaying errors

I'm attempting to submit step one of my 3 page form via ajax for my Laravel application and I have it set up so that when validation fails on this submission it will submit back with the validation errors which it dos however it still proceeds to the

Laravel's Delayed Service Provider "Provides" Not to Be Called

I have the following definition: namespace App\Providers; use Illuminate\Support\ServiceProvider; use App\SomeClass; class SomeProvider extends ServiceProvider { protected $defer = true; public function register() { $this->app->bind(SomeClass::class

laravel $ request- & gt; input () does not work

I'm trying to retrieve a single input from laravel request $request->input('username') But it returns undefined in ajax response, I tried: $request->only('username') as well as: $request->username` but none of them work, exept for: $request->a

Get the name of all relationships in the laravel5 model

I have model include of several relation for example like this: public function NewsCategory() { return $this->belongsTo("News\Model\NewsCategory"); } public function NewsImage() { return $this->belongsTo("News\Model\NewsImage");

Download the live laravel project

How to upload larval project to server? I have uploaded larval website which is perfectly working in local computer, but when I uploaded to server same like as I am uploading other PHP website, but it is not going to view it shows a blank screen. Ple

Replace the 5.2 laravel authentication method in AuthController

I'm still very noobish with Larvel, so i can't figure out how to do this: I'm stuck at the login system. I'm trying to understand how i can prevent inactive users to use the application. Edit With inactive users i mean those users which has the recor

Show name instead of Laravel ID

I have two tables; Students and Grade. Students contains foreign key grade_id referencing Grade. For viewing students, I have used following code; Controller: public function viewStudent() { $students=Student::all(); return $students('grade_id'); $gr

Custom login validation in Laravel 5.2

In my User model I have a status field. I only want to allow users with the status of 'active' to log in. I was thinking of creating a custom Validator in AppServiceProvider but unsure where to use it when the user is logging in. Can I overwrite the

How to page the Eloquent query with orderBy. at the join

Here i want my top posts of the week or month according to comments of each post.The query is working but i am unable to paginate.Please help! $top = Post::having('created_at', '>=', $time) ->selectRaw('posts.*, count(*) as `aggregate`') ->join('

Can not install mongodb in laravel

I am trying to setup mongodb for Laravel Framework version 5.2.29. My mongo php driver version is ext-mongo 1.6.8 The mongo PHP extension. My Mongo version is 3.2 I have installed mongodb successfully, i can start mongod and mongo and create collecti

Laravel 5.2 php artisan migrate: restore error

I use Laravel 5.2 and I created database tables by running php artisan make:migration create_categories_table --create=categories and php artisan make:migration create_posts_table --create=posts and then I run php artisan migrate, and tables are crea

Laravel 5.2 Auth relation

I'm having a problem with a relationship through the Users model when using the Auth class. The relationship I think is suppose to be $this->hasMany('App\Product') and also will it return the newly saved id back to a variable through this method. Whe

TokenMismatchException in VerifyCsrfToken.php Line 67

I know that this is a known error with things like forms in Laravel. But I am facing an issue with basic authentication in Laravel 5.2. I created the auth using Laravel; php artisan make:auth Now I have the same copy of code on my server and my local