Skip to content

[Maybe BUG] Laravel 5 softDeletes Model cause blank white page response if table don't have deleted_at column #3514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 171 commits into from

Conversation

darkcyber
Copy link

Hi,

My Options table contain id, name, value, autoload columns.

My routes.php

<?php
Route::get('/settings', 'SettingsController@index');

Here is my SettingsController.php

<?php namespace App\Http\Controllers\Admin;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Option;

class SettingsController extends Controller {

    public function index()
    {
        $options = Option::all();
        return dd($options);
    }

Here is my Option.php model

<?php namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
* 
*/
class Option extends Model
{
    use SoftDeletes;
    protected $fillable = ['id', 'name', 'value', 'autoload'];
    protected $table = 'options';
}

If I visit myproject.dev/settings it will give me blank white page without any error, try to delete views cache at storage folder didn't work.

Try with artisan tinker give me some idea

use App\Option;
dd(Option::all());

It give me Illuminate\Database\QueryException with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'coeg_options.deleted_at' in 'where clause' (SQL: select * fromcoeg_optionswherecoeg_options.deleted_atis null)

Then I add deleted_at column at my table, finally it work and I didn't get blank white pages anymore.

Maybe will be good if Laravel check deleted_at column for model which use SoftDeletes and throw an error if deleted_at column not found, just like artisan tinker error above.

jonathantorres and others added 28 commits July 17, 2015 23:27
Sorted by alphabetic.
Bump Laravel Elixir version
Error message for JSON validation
Ensure the default views always use HTTPS for the loading of fonts. This is overall a good practise to follow.
Use https rather than // for google fonts in default views.
According to the docs, the sqlite database should be located within the "database" folder.
Replace storage_path with database_path helper
Signed-off-by: crynobone <crynobone@gmail.com>
[5.1] Use $this instead of parent.
@asoorm
Copy link

asoorm commented Oct 6, 2015

Don't use softDeletes in your model, and Laravel will know not to look
at the deleted_at column

On 06/10/2015 10:26, Dark Cyber wrote:

Hi,

My |Options| table contain |id, name, value, autoload| columns.

My |routes.php|

|<?php Route::get('/settings', 'SettingsController@index'); |

Here is my |SettingsController.php|

|<?php namespace App\Http\Controllers\Admin; use App\Http\Requests; use
App\Http\Controllers\Controller; use App\Option; class
SettingsController extends Controller { public function index() {
$options = Option::all(); return dd($options); } |

Here is my |Option.php| model

|<?php namespace App; use Illuminate\Database\Eloquent\Model; use
Illuminate\Database\Eloquent\SoftDeletes; /** * */ class Option
extends Model { use SoftDeletes; protected $fillable = ['id', 'name',
'value', 'autoload']; protected $table = 'options'; } |

If I visit |myproject.dev/settings| it will give me blank white page
without any error, try to delete views cache at storage folder didn't
work.

Try with artisan tinker give me some idea

|use App\Option; dd(Option::all()); |

It give me |Illuminate\Database\QueryException with message
'SQLSTATE[42S22]: Column not found: 1054 Unknown column
'coeg_options.deleted_at' in 'where clause' (SQL: select *
from|coeg_options|where|coeg_options|.|deleted_at|is null)|

Then I add |deleted_at| column at my table, finally it work and I
didn't get blank white pages anymore.


    You can view, comment on, or merge this pull request online at:

#3514

    Commit Summary


Reply to this email directly or view it on GitHub
#3514.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.