laravel-4

Laravel resource controllers for both API and non-API use

醉酒当歌 提交于 2019-12-06 05:10:39
问题 After creating a resource controller PhotosController for a website that also does AJAX calls to the API, it appears that the resource controller can be used on both the normal website and as the API. This displays a HTML page for Photo with id = 1 http://domain.com/photos/1 and Javascript uses the following which updates the Photo resource and returns a JSON response PUT http://domain.com/api/v1/photos/1 Question: Will we have 2 PhotoControllers , one to handle API usage and one for non-API?

SSL certificate error: self signed certificate in certificate chain in using Twilio on my Laravel Website

♀尐吖头ヾ 提交于 2019-12-06 05:01:09
I am testing my codes on my localhost and I tried dtisgodsson/laravel4-twilio to apply on my current website but I got this error SSL certificate problem: self signed certificate in certificate chain right after I put this code inside my index.blade.php: Twilio::to('119061539155')->message('This is so, damn, easy!'); What do I need to do to get rid of this error? rickyrobinett Twilio Developer Evangelist here. This error is caused by not having an up-to-date bundle of CA root certificates with your PHP installation. You need to download the latest CA root certificate bundle and update your php

Many to Many join Laravel Eloquent

回眸只為那壹抹淺笑 提交于 2019-12-06 04:46:59
I'm using Laravel 4.1 and i want to make a join with Eloquent: So I have 3 table as: Table 1 (pools): id, name Table 2 (contribution): id, amount, pool_id, contributer_id Table 3 (contributers): id, last_name By the way i have 3 models : Pool, Contributer, and Contribution Thanks in advance. You can do it this way: $result = Pool::join('Contribution', 'Pool.id', '=', 'Contribution.pool_id') ->join('Contributer', 'Contribution.contributer_id', '=', 'Contributer.id')->get(); Or, if you define the relationships in models, such as: class Pool extends Eloquent { ... public function contributers(){

Laravel API controller structure?

微笑、不失礼 提交于 2019-12-06 04:22:58
问题 Which one this controller structure for user api make sense Separate controller for UI and API for every api version /app/controllers/UsersController.php /app/controllers/api/v1/ApiUsersController.php or Separate controller for UI and API and handle versioning in code /app/controllers/UsersController.php /app/controllers/api/ApiUsersController.php or Use single controller, detect /api/ call within router. Return html/json depending on the url. /app/controllers/UsersController.php 回答1:

Laravel Exception after page is refresh - OpenSSL extension is required

折月煮酒 提交于 2019-12-06 04:20:57
I am newbie in Laravel. I am using windows 7. I have downloaded and created a laravel project inside xampp inside htdocs folder.I have uncommented the statement, extension=php_openssl.dll inside php.ini . When I type the http://localhost/laravel/public/ in the browser, it shows the home page. When I refresh the page I get an exception like this. When I remove the cookies and session variables in the browser settings, it will show the home page for once and if I refresh the page after,it shows the above page again. NB: I have edited nothing in the project.I just tried to run the project After

Laravel 5 __construct() argument passing error

北城以北 提交于 2019-12-06 04:18:56
So I am trying to group all my validation rules into its respective files in folders for easy maintenance. Below is how my folder structures look: Project --app --config --(more folders) --domains ----App --------Entities --------Repositories --------Services --------Validators ----Core --------Validators So what I wanted to achieve is under Core\Validators I created a LaravelValidator.php which look like this <?php namespace Core\Validators; use Validator; abstract class LaravelValidator { /** * Validator * * @var \Illuminate\Validation\Factory */ protected $validator; /** * Validation data

Pass fixed variable from route to controller in Laravel

早过忘川 提交于 2019-12-06 04:12:06
I'm trying to pass a variable through my route to my controller, but I have multiple routes (categories) leading to the same controller i.e. Route::get('/category1/{region}/{suburb?}', 'SearchController@search'); Route::get('/category2/{region}/{suburb?}', 'SearchController@search'); Making /category1, 2, etc. to be a parameter /{category} is not an option and I don't want to make separate controller function for each category. How do I send the first segment of the url to my search controller? i.e. category1 or category2? At present controller is as follows: public function search($region,

Laravel: View [layouts.default] not found

百般思念 提交于 2019-12-06 04:10:19
I installed a bundle in my project that defines it's own views. While navigating through the site after making some changes, I found that all of my actions that happen with the bundled views work fine, but when I go back to the head route, I get an error message: View [layouts.default] not found. (View: /var/www/app/views/home.blade.php) The file app/views/home.blade.php definitely exists. The closure for my head route looks like this: Route::get('/', array('as' => 'home', function() { return View::make('home'); })); What could have changed the structure of my views? EDIT: Here's the contents

Querying on related models using Laravel 4 and Eloquent

杀马特。学长 韩版系。学妹 提交于 2019-12-06 04:02:25
Using Laravel 4 I have the following models and relations: Event which hasMany Record which hasMany Item. What I would like to do is something like this Item::where('events.event_type_id', 2)->paginate(50); This of cause doesn't work as Eloquent doesn't JOIN the models together when retrieving the records. So how do I go about this without just writing the SQL myself (which I would like to avoid as I want to use pagination). What you want is eager loading . It works like this if you want to specify additional constraints: Item::with(array('events' => function($query) { return $query->where(

Querying on related models using Laravel 4 and Eloquent

本小妞迷上赌 提交于 2019-12-06 04:00:34
Using Laravel 4 I have the following models and relations: Event which hasMany Record which hasMany Item. What I would like to do is something like this Item::where('events.event_type_id', 2)->paginate(50); This of cause doesn't work as Eloquent doesn't JOIN the models together when retrieving the records. So how do I go about this without just writing the SQL myself (which I would like to avoid as I want to use pagination). What you want is eager loading . It works like this if you want to specify additional constraints: Item::with(array('events' => function($query) { return $query->where(