laravel-4

Laravel - Search Facility on site using Eloquent

淺唱寂寞╮ 提交于 2019-12-13 08:56:25
问题 I'm a laravel newbie!!! And struggling to find out how to create a search and return the results. Here's all my code on gist https://gist.github.com/anonymous/8289692 I've put everything in the gist from the form to the route, the controller and the model! /* Route */ Route::get('/search/{q}', 'HomeController@search'); /* Form from web page */ <form class="navbar-form navbar-left" role="search" action="/search/" method="post"> <div class="input-group"> <input type="text" class="form-control"

How do I fetch name of locale (language) not just a locale string, but rather the name of that language in LARAVEL?

和自甴很熟 提交于 2019-12-13 08:27:27
问题 How do I fetch name of locale (language) not just a locale string, but rather the name of that language in LARAVEL? {{ app()->getLocale() }} 回答1: Laravel doesn't have this information. You need to add it manually by creating table or config with locales and their languages names. 回答2: I resolved this by adding an entry to a translation file using Laravel Localization. https://laravel.com/docs/5.7/localization In AppServiceProvider@boot : $language = Settings::get('language'); // Fetch saved

How to debug Laravel 5 projects?

拟墨画扇 提交于 2019-12-13 08:17:48
问题 I ran command php artisan optimize and changed debug settings in app.php file to be 'debug' => 'true', and added 'everyone' to have full access over 'storage' folder. I don't know what else I can do to let debugger work in my Laravel 5 project. I'm stuck with 'Whoops, looks like something went wrong' message. Any Ideas?? 回答1: The error you are receiving is a general error, likely server-side configuration. Without any information on your setup it will be pretty hard to determine what your

Invalid parameter number given with pdo's prepared statement

淺唱寂寞╮ 提交于 2019-12-13 08:17:20
问题 Hello I have made a query to select certain values from the database. Unfortunately I am getting this error message: Invalid parameter number The code is as followes $vehicles = DB::select( DB::raw(" SELECT v.id, v.brand, v.type, v.description, v.airco, v.seats, v.hourly_rent FROM vehicle as v WHERE v.id NOT IN((SELECT v.id FROM vehicle as v INNER JOIN reservation as r on r.`vehicle_id` = v.id WHERE r.status_id in(3,4,5) AND ( ( (:start >= r.startdate AND :eind <= r.enddate ) OR (:start <= r

Composer Update error in Laravel 4 after renaming a controller file

不羁岁月 提交于 2019-12-13 08:04:52
问题 hi I got error in my composer update. This happened because I got same class in a two controller file. TravelerControler.php TravelerControler-backup.php <- just for backup but it calls the method not the TravelerControler.php Some cases my new method that I applied in TravelerControler.php didn't call so I remove the TravelerControler-backup.php file and got 500 error. so I do composer update and this is the result. First I do composer self-update then do the composer update and got this

Laravel Routing- Multiple Route

杀马特。学长 韩版系。学妹 提交于 2019-12-13 07:45:38
问题 I'm using laravel to make an API. The following endpoints will be available: Currently I have: Route::get('/{appname}/{network}/{device}', function() { return 'Hello World'; }); This services /appname/network/device/ but what I would like is so it can be the following but in one route without the need for additional routing: Route::get('/{appname}', function() { return 'App Name'; }); Route::get('/{appname}/{network}', function() { return 'App Name / Network'; }); Route::get('/{appname}/

Laravel download file from S3 route (not open in browser)

痞子三分冷 提交于 2019-12-13 07:41:15
问题 I have the following route that will load a file from the given URL, I need this to actually download the file (mp4, jpg, pdf) rather than open in the browsers in built viewer. // Download from CDN Route Route::get('cdn/{url}', function($url) { return Redirect::away($url); })->where('url', '(.*)'); All files are stored externally so apparently Resource::download() wouldn't actually work. All I have available to me is the Amazon URL: https://mybucket.s3.amazonaws.com/folder/filename.pdf Any

Environment issue in Laravel

主宰稳场 提交于 2019-12-13 07:17:13
问题 $env = $app->detectEnvironment(array( 'local' => array('*localhost*'), 'test' => array('chan.app'), )); This is how I set in boostrap/start.php, and I set ip in hosts file 127.0.0.1 localhost 127.0.0.1 chan.app No matter I type http://localhost/ or http://chan.app , App::environment() always reveal production , therefore I can't change database config for it. 回答1: Open your CMD (Mac, Linux, and Windows) and type the command: hostname this will return the name of your computer. Then use that

Relationship between 3 tables

独自空忆成欢 提交于 2019-12-13 06:38:58
问题 I have a mysql DB with 3 tables: - Campaigns id code name - Columns id name - Values id idColumn value The relationship beetween Campaigns and Columns is many to many: - ColumnsCampaign id idColumn idCampaign and the relationship beetween Columns and Values is one to many. I have this query that returns all values for each campaign: return Campaigns::addSelect('id','code','name') ->whereHas('typeCampaign', function ($q) use ($idTypeCampaign,$idMenu) { $q->where('typeCampaign.id',

Laravel Multi-Aiuth with multiple table session set till user logout

久未见 提交于 2019-12-13 06:34:40
问题 I have implemented multi-auth in laravel-4.2 with multiple tables So accordingly my login view posts 3 values,1st is username,2nd is password and 3rd is a value from dropdown which is mathches the same value as Auth::<3rd Value>()->attempt,Which helps me to log in with requested table,And suppose if 3rd value is null then Auth::user()->attempt come in use. for multi auth I am using 'ollieread' pakage Auth Implementation code is auth.php: <?php return array( 'multi' => array( 'BSc' => array(