laravel-4

Laravel Blade - pass variable via an @include or @yield

南笙酒味 提交于 2019-12-05 02:01:58
I need to pass a variable to an included Blade file. I have attempted this two-ways; however, neither have been successful. Pass a variable, title , to the included file: @section('left') @include('modal', ['title' => 'Hello']) @stop Use @yield and set the section: @section('left') @include('modal') @section('title') Hello @stop @stop I am using Laravel 4.2. I am unaware if what I am trying to do is possible, but I imagine it is. According to the documentation , the include -way should be the way to do it: Including Sub-Views @include('view.name') You may also pass an array of data to the

302 redirect after CORS preflight

蹲街弑〆低调 提交于 2019-12-05 01:59:26
I'm running into a problem with a 302 redirect after my CORS preflight has successfully returned a 200 status. I'm currently building an app using Laravel 4.1 and Angular 1.2 as well as my own OAUTH2 server. The error that Chrome/FF/Safari are sending back to me is: XMLHttpRequest cannot load http://localhost.api/api/v1/tracks?$filter=id%20eq%20guid%27d7de10ba-e353-455b-a3cb-ced9b4965141%27& . The request was redirected to ' http://localhost.api/session/invalid ', which is disallowed for cross-origin requests that require preflight. I assume whats causing my issue is the "redirect" thats

laravel4 response very slow and take much time to load

风流意气都作罢 提交于 2019-12-05 01:53:27
问题 I did a lot of search and no solution worked for me. Firstly, I have two projects on the same server, one using CodeIgniter and the other using Laravel. The one which uses Laravel occasionally loads very slow This image shows empty page written with Laravel And this image shows that user waits for about 33 sec. Sometimes, this time comes from Receiving I had a quick look for some websites that run Laravel. I noticed that this issue exists there too, you can try October CMS . Finally this is

Array_unique on a laravel eloquent collection

删除回忆录丶 提交于 2019-12-05 01:47:06
Not sure if this is possible but im trying to run array_unique over a collection of items i have, to remove duplicates. Although i cannot get it working. my controller logic: // init models $jobs = Job::search(); $countries = $jobs->get()->map(function( $job ) { return $job->country; }); $countries = array_unique( $countries->toArray() ); although this gets a "Array to string conversion" error You can have unique values in your DB results using distinct or group by in your select clause. But, if you really need to have unique values over an array of object you can do the following: $uniques =

Str::slug alternative for hindi and arabic strings?

浪子不回头ぞ 提交于 2019-12-05 01:41:56
问题 I use Str::slug to generate friendly URL's, however Str::slug() method returns null on arabic and hindi strings. Probably chinese, japanese, korean and those charsets too. For example: return Str::slug('मनोरंजन'); //null How can I solve this issue efficiently? 回答1: I have faced this problem when I was working with Arabic language, so I've made the following function which solved the problem for me. function make_slug($string = null, $separator = "-") { if (is_null($string)) { return ""; } //

Laravel: Escape “LIKE” clause?

此生再无相见时 提交于 2019-12-05 01:38:50
How can I escape a LIKE clause in Laravel/Eloquent? e.g., $search = Input::query('sSearch', ''); if($search !== '') { $paginatedBookings->where('first_name', 'LIKE', '%' . $search . '%'); } If $search contains a % or _ they need to be escaped. The other answer forgets about escaping the escape character itself, here is a more robust solution: /** * Escape special characters for a LIKE query. * * @param string $value * @param string $char * * @return string */ function escape_like(string $value, string $char = '\\'): string { return str_replace( [$char, '%', '_'], [$char.$char, $char.'%', $char

Multiple Auth sessions in Laravel 4

喜欢而已 提交于 2019-12-05 01:30:05
问题 The project I'm currently working on is split up in an admin console and the normal frontend. Both front and backend are in the same Laravel instance. In the frontend I'm trying to create a user login system that works exclusively for the frontend. It uses a different table and model and it has different relations as oposed to the User model for the admin. What I can't figure out is a way to use the Laravel Auth class for both systems. Logically Auth uses one single config file, and more to

laravel 4.2 queries with an encrypted column

早过忘川 提交于 2019-12-05 01:27:01
问题 i currently have this code in my controller which display a set of records here is my code public function view() { $title = "View Guardian Information"; $vPa = DB::table('dbo_guardianinformation') ->join('dbo_cities', 'dbo_guardianinformation.CityID', '=' , 'dbo_cities.CityID') ->select('dbo_guardianinformation.ParentAccountID','dbo_guardianinformation.FirstName','dbo_guardianinformation.LastName','dbo_guardianinformation.Roles', 'dbo_guardianinformation.Address','dbo_cities.CityName','dbo

Laravel 4 Migration error - creates two auto_increment primary keys fields

蹲街弑〆低调 提交于 2019-12-05 01:04:46
I made a migration with this setup: $table->increments('id'); $table->integer('user_id', 10)->unsigned(); // this is meant to be used as a foreign key After doing php artisan migrate it returns an error: [Exception] SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key (SQL: create table `transactions` (`id` int unsigned not null auto_increment primary key, `user_id` int unsigned not null auto_increment primary key) default character set utf8 collate utf8_unicode_ci) (Bindings: array ()) I didn't

Composer hangs on “Resolving dependencies through SAT” on 4.2

删除回忆录丶 提交于 2019-12-05 00:55:34
Things I've tried: Removing everything except for Laravel (version 4.2.*) - This completes but still hangs for around 5 minutes Updating composer Removing /vendor Doing clean Laravel 4.2 install (hangs around 3 minutes) Doing clean Laravel 5 install (doesn't hang at all) Turning off xdebug completely (doesn't seem to make a difference) With all my packages, I've seen composer complete but only when I left it running overnight. I can't deploy to forge at all because it times out! This only started happening two or so weeks ago. For all looking for an answer...here's what helped increase