laravel-4

Laravel 4 testing session in controllers

不羁岁月 提交于 2019-12-06 06:57:17
问题 I have a problem with testing controllers in Laravel 4. I have the next code: public function getRemind() { $status = \Session::get('status'); $error = \Session::get('error'); $email = \Session::get('email'); return \View::make('admin/reminds/remind_form', compact('status', 'error', 'email')); } And I want to test if correct data passed in views by controller: public function testGetRemind() { \Session::set('status', 'status'); \Session::set('error', 'error'); \Session::set('email', 'email');

How to make update query with parameters and CASE statement in Laravel 4

送分小仙女□ 提交于 2019-12-06 06:39:49
I'm trying to create mysql UPDATE query that will take parameters. In addition I want to append to the end of the field if the field isnt empty. For that I'm using CASE statement. Here's my query in doctrine (from silex): $query = "UPDATE table SET filed = ( CASE WHEN field = '' THEN :param1 ELSE concat(field, :param1) END) WHERE id=:param2"; $app['db']['test_db']->executeUpdate($sql, array('param1' => $user_text, 'param2' => $selected_id)); Now I want to convert it to fluent or raw query so I can use it in Laravel 4. Here's my code: $param1 = "String..."; // user string $param2 = 45; // id DB

Laravel 4 : Pagination and Sort Header

爱⌒轻易说出口 提交于 2019-12-06 06:33:57
I am having a problem with Laravel Pagination and Header Sort, Let me show you what I have. My current page I am working with is "admin/admins" where i have pagination and headers. 1) AdminController code: // get for admin/admins page // page to list all the Admin users public function getAdmins($sort= NULL , $sort_dir = NULL) { // CACHE SORTING INPUTS $allowed = array('first_name', 'last_name', 'email', 'activated', 'created_at'); // add allowable columns to search on $sort = in_array($sort, $allowed) ? $sort : 'first_name'; // if user type in the url a column that doesn't exist app will

Laravel 4 restful delete a record with a resource controller

对着背影说爱祢 提交于 2019-12-06 06:27:21
问题 I am new to Laravel framework but I really like it. My biggest problem is I have been searching on how I can delete a single record using resource controller. Controller method: public function destroy($id) { $department = Department::find($id); $department->delete(); } Delete link I have tried: <a class="btn btn-xs btn-danger" data-method="delete" href="{{ URL::to('department/' . $department->id) }}"><i class="icon-remove"></i></a> Javascript: <script type="text/javascript"> $(function(){ $(

Actual directory overwriting Laravel route

会有一股神秘感。 提交于 2019-12-06 06:03:45
I'm working in my first project with Laravel, it's a simple website with an admin panel: In my "public" folder I have a directory called "admin" where I put all the styles and scripts corresponding to the admin panel. I've also defined a route in my app to handle the "admin" GET: Route::get('/admin', 'Admin\DashboardController@index'); The problem is that since I have that "admin" folder in my public directory Laravel is ignoring the "admin" route I defined, so I can't access the proper controller. I'm suspecting it has something to do with the .htaccess but I'm not sure how to solve it. This

General error: 1364 Field 'remember_token' doesn't have a default value

橙三吉。 提交于 2019-12-06 05:49:18
I m new to laravel. I wanted to insert the admin credentials into database. public function verify() { $username = Input::get('username'); $password = Input::get('password'); if (!Admin::count()) { $user = new Admin; $user->username = Input::get('username'); $user->password = $user->password = Hash::make(Input::get('password')); $user->save(); return Redirect::to('/admin/login'); } else { if (Auth::attempt(array('username' => $username, 'password' => $password))) { echo("i m in if"); if (Session::has('pre_admin_login_url')) { $url = Session::get('pre_admin_login_url'); Session::forget('pre

Web app and API in same Laravel project?

一个人想着一个人 提交于 2019-12-06 05:44:10
问题 I am trying to figure out the best way to structure a new project that I am about to embark on. We currently have a web app and a mobile app which are both fed data by an API. Currently the web app is done on an installation of CodeIgniter and the API is done on a separate installation of CodeIgniter. For data, the web app makes calls to the API and then handles the returned data. At this point it looks like we are doing to switch into Laravel for the web app and I was thinking that it might

Seeding database with path from code?

♀尐吖头ヾ 提交于 2019-12-06 05:35:08
问题 I've been using Laravel's migrations with the path parameter like so: Artisan::call('migrate', array('--path' => 'path/to/my/Migrations')); Is there anyway I can run the seed command in the same way? I have a number of seed files I want to use but I don't want to run them all at the same time. Any advice appreciated. Thanks 回答1: Instead of --path you can set --class with namespace to Seeder class. Artisan::call('db:seed', [ '--class' => 'Namespace\Seeds\DatabaseSeeder' ]); This work on

Laravel 4: Publishing a Package's Assets

99封情书 提交于 2019-12-06 05:15:08
问题 How to publish package assets? I've found a tutorial here: http://laravel-recipes.com/recipes/279 But when I tried to publish assets from my workbench, I get this error: [RuntimeException] Unable to publish assets. asset:publish [--bench[="..."]] [--path[="..."]] [package] My command code is: php artisan asset:publish --bench=Mypackage How can I get my package assets to be published. Thank you. 回答1: When you want to publish assets that are developed and stored in your workbench you should use

Laravel 4 - Mcrypt extension required

最后都变了- 提交于 2019-12-06 05:11:39
I just finished installing Ubuntu, setting up Apache, MySQL, and PHP. I then decided to install the Laravel framework. I ran a composer install and got the following error: Mcrypt PHP extension required. Script php artisan clear-compiled handling the post-install-cmd event returned with an error I then installed mcrypt deal and all that remained was the artisan error. I decided to go on about my business because I couldn't find a solution online. Now I am starting my first laravel project. I ran php artisan migrate:install and it says Mcrypt PHP extension required. What can I do to fix this? I