laravel-4

Laravel Relationships

≯℡__Kan透↙ 提交于 2020-01-20 04:34:04
问题 I've been looking over relationships in Laravel 4 in the documentation and I'm trying to work out the following. I have a table in my database called 'events'. This table has various fields that mainly contain ID's that relate to other tables. For example, I have a 'courses' table. The events table contains a field called 'course_id' which relates to the ID of the 'id' field in the courses table. So basically, I'm after some advice on how you go about relating the two (belongsTo()?) and then

Laravel filter reset after next page click in paginate

霸气de小男生 提交于 2020-01-19 18:05:06
问题 I have create table where showing data. I also add few filters to filter data. Using paginate i show 20 records per page. After select filter and click search records in table filter with paginate in first page but as soon as i click next page filters getting reset. How to stop filters getting reset? Below is my code, public function index() { $agos = DB::table('orders') ->leftJoin('companies', 'orders.company_id', '=', 'companies.id') ->select(DB::raw('orders.id, companies.name, orders.type,

How to use paginate() with a having() clause when column does not exist in table

纵饮孤独 提交于 2020-01-18 22:44:54
问题 I have a tricky case ... Following database query does not work: DB::table('posts') ->select('posts.*', DB::raw($haversineSQL . ' as distance')) ->having('distance', '<=', $distance) ->paginate(10); It fails with message: column distance does not exist. The error occurs when paginate() tries to count the records with select count(*) as aggregate from {query without the column names} As the column names are stripped, distance is not known and an exception is raised. Does somebody have a work

How to use paginate() with a having() clause when column does not exist in table

∥☆過路亽.° 提交于 2020-01-18 22:44:53
问题 I have a tricky case ... Following database query does not work: DB::table('posts') ->select('posts.*', DB::raw($haversineSQL . ' as distance')) ->having('distance', '<=', $distance) ->paginate(10); It fails with message: column distance does not exist. The error occurs when paginate() tries to count the records with select count(*) as aggregate from {query without the column names} As the column names are stripped, distance is not known and an exception is raised. Does somebody have a work

Reset user passwords in Laravel framework

偶尔善良 提交于 2020-01-17 12:28:05
问题 I'm trying to implement the password reminder according to this: http://laravel.com/docs/4.2/security I used the artisan commands : php artisan auth:reminders-table php artisan migrate and added this to my routes: Route::controller('password', 'RemindersController'); Route::get('forgotpassword', 'RemindersController@getRemind'); so now when I go to this page : myapp/forgotpassword I get the password.remind view which has the following code: <?php include_once(app_path()."/includes/header.php"

Laravel FrozenNode Administrator run in maintenance mode

a 夏天 提交于 2020-01-17 08:29:30
问题 My question is: How can I leave the Frozennode administrator runs normaly on Laravel Maintenance Mode? This is what I got in global.php App::down(function() { return Response::view('maintenance', array(), 503); }); Thanks! 回答1: There is actually another way, more straightforward. As you can read in Laravel documentation, returning NULL from closure will make Laravel ignore particular request: If the Closure passed to the down method returns NULL, maintenance mode will be ignored for that

Laravel 4 Public Functions

会有一股神秘感。 提交于 2020-01-17 06:38:30
问题 I've got a question. I made a function that says if 'type' (a column in my database) is equal to five, it'll display buttons that others can't view. The problem is when I log out or log into a user that doesn't have type equals to five, it displays an error. How could I do this in a function? I tried various things, but it always displays errors. Here's my method... <?php public function get_dash() { $roles = Auth::user()->type; if ($roles == '5') { return View::make('admin.dash')->with(

Laravel 4 Public Functions

浪尽此生 提交于 2020-01-17 06:38:25
问题 I've got a question. I made a function that says if 'type' (a column in my database) is equal to five, it'll display buttons that others can't view. The problem is when I log out or log into a user that doesn't have type equals to five, it displays an error. How could I do this in a function? I tried various things, but it always displays errors. Here's my method... <?php public function get_dash() { $roles = Auth::user()->type; if ($roles == '5') { return View::make('admin.dash')->with(

laravel 4 - pull similar data in multiple controllers into many views

余生颓废 提交于 2020-01-17 05:19:15
问题 I have users routes like that: user/13/posts/10 user/13/videos/443 user/13/items/4002 And i want to pull all the data related to 'user/13' every time posts/videos/items views are loaded. i am also loading the sidebar @include('inc/blog-sidebar') and this file contain data that is the same in all the views and related to 'user/13'. what is the best way to pull all this information without doing it per function within every controller? I have tried view:composer within the routes.php (which is

Laravel 4 - auth.basic filter session doesn't expire | How to expire auth.basic session

懵懂的女人 提交于 2020-01-17 01:35:19
问题 I have a simple admin area where I can update some aspects of a website. since I'll be the only one accessing it I thought of using the auth.basic functionality of Laravel 4. I built a group on my routes.php file that adds the auth.basic filter to several resources at once: //routes.php // Password protected routes Route::group(['before' => 'auth.basic'], function () { Route::get('admin', ['as' => 'admin', 'uses' => 'AdminController@index']); Route::resource('admin', 'AdminController'); Route