laravel-4

How to see laravel view without php Artisan serve

旧城冷巷雨未停 提交于 2019-12-03 17:18:50
How can I see the Laravel view without an artisan command CLI . I don't have CLI from my hosting provider, I only have access to FTP , to run Laravel I have to use this command in CLI : php artisan serve --port=8080 --host=0.0.0.0 How can I get the view without this command? Thanks. php artisan serve is not ment for use in production environments because it uses PHP5 build in webserver. If you're with a hosting provider, they probably run Apache and you can just serve your app via Apache. Have a look at the documentation on php.net if you want to know more about the build in webserver. PHP

Override section in a laravel blade template throwing undefined variable errors

梦想与她 提交于 2019-12-03 17:14:54
I am using Laravel 4 and blade templates, and running into an issue when I try and extend a template. In my layout I have @yield('content') and in my page I have @section('content') Welcome {{ $name }} @stop which works fine, I've created another page very similar to my first, and just want to change override the admin content section. The other sections in the template are fine. so I extend my page, and do @section('content') Hello! @stop I get an undefined notice with the $name variable. I tried @section('content') Hello! @overwrite and same deal, I get the notice error. I checked my

Laravel Eloquent - Encrypting/Decrypt Data on call

倖福魔咒の 提交于 2019-12-03 17:13:24
问题 I can use Crypt to encrypt/decrypt my data. I want to encrypt some information in my db (such as the name, email, phone number to name a few). Assuming that I want EVERYTHING to be encrypted, I want to be able to do this in the background by itself, which I can perform by overwriting the create and save functions: // For instance, the save() function could become public function save(array $options = array()) { foreach ($this->attributes as $key => $value) { if (isset($value)) $this-

Laravel 4.1 Eager Loading Nested Relationships with Constraints

≡放荡痞女 提交于 2019-12-03 17:09:36
问题 I am trying to get Eager-Loading nested relationships, with constraints, to work. Everyone seems to be giving the same example of eager-loading nested relationships: $users = User::with('posts.comments')->get(); What I want to do instead is get all the the Users related to a post of a given id. But at the same time, I also want to get the comments associated with that post. In 4.1, I to achieve the latter, I could do: $comments = Comment::whereHas('post', function($query) { $query->whereId(1)

laravel 4: how to subtract one from current value of column when updating rows?

元气小坏坏 提交于 2019-12-03 16:52:03
问题 I was wondering how to perform something like this: Table::update(array('position'=>'position+1')); As far as I know, laravel 4 handles 'position+1' as a string, thus is becomes 0. I want to perform something like UPDATE table SET position = position + 1 Can I do that using eloquent? EDIT: nevermind, doh.."DB::table('users')->increment('votes');" 回答1: Simply make use of the increment method: DB::table('users')->increment('position'); The same is valid for decrement : DB::table('users')-

How to reset auto increment in laravel user deletion?

六月ゝ 毕业季﹏ 提交于 2019-12-03 16:31:56
问题 I have been struggling to find out a way to reset the auto increment value in Laravel 4 but it seems that this functionality is not embedded in laravel 4 at least for now. so i did it this way: $user = User::find($user_id); if ($user) { if ($user->delete()){ DB::statement('ALTER TABLE users AUTO_INCREMENT = '.(count(User::all())+1).';'); echo json_encode('User Was Deleted Successfully..'); } } each time i delete a user from the database i set the auto increment pointer to the number of all

Laravel 4 debugging not working

情到浓时终转凉″ 提交于 2019-12-03 16:29:22
问题 It's extremely frustrating that I have 'debug' => true in the app config but all Laravel is showing is "Whoops, looks like something went wrong." For the love of coding, does somebody know how to get debugging to work? 回答1: I have faced the same problem. Laravel was showing only "Whoops, looks like something went wrong." but this line and not showing the actual error. Then I have checked the app/config/app.php file and changed "debug" => false to "debug" => true and it worked perfectly. You

Import of 50K+ Records in MySQL Gives General error: 1390 Prepared statement contains too many placeholders

六月ゝ 毕业季﹏ 提交于 2019-12-03 16:18:58
问题 Has anyone ever come across this error: General error: 1390 Prepared statement contains too many placeholders I just did an import via SequelPro of over 50,000 records and now when I go to view these records in my view (Laravel 4) I get General error: 1390 Prepared statement contains too many placeholders. The below index() method in my AdminNotesController.php file is what is generating the query and rendering the view. public function index() { $created_at_value = Input::get('created_at

Detect changes when saving Laravel 4: Eloquent

和自甴很熟 提交于 2019-12-03 16:11:06
问题 I'm using the Laravel 4 framework and I am trying to work out a way to display notifications depending on whether a save() was successful or not. Here's what I have so far: if($user->save()) { Session::flash('success','woohoo success'); } else { Session::flash('error','uhoh error'); } return Redirect::action('UsersController@show', array('users' => $id)); My problem is that it always returns true when a user is saved, even if no changes have been made to the database (I know this from the

Laravel 4: using controller to redirect page if post does not exist - tried but failed so far

荒凉一梦 提交于 2019-12-03 16:02:45
I'm working with Laravel 4, I have a page that shows posts e.g. example.com/posts/1 shows the first post from the db. What I want to do is redirect the page to the index if someone tries to go to a url that doesn't exist. e.g. if there was no post number 6 then example.com/posts/6 should redirect to example.com/posts Here is what I have, is it on track at all? public function show($id) { $post = $this->post->findOrFail($id); if($post != NULL) { return View::make('posts.show', compact('post')); } else { return Redirect::route('posts.index'); } } Any ideas? Thanks :) Exactly as Rob explained,