laravel-4

how to validate image dimension before insert into database in laravel

有些话、适合烂在心里 提交于 2019-12-20 04:37:29
问题 Iam new in laravel .im trying to validate dimensions of image .i want dimensions minimum(width=100,height=50).iam using validation code in controller.php is here 'galimg'=>'required|max:200kb|DimensionMin(300,300)|Mimes:jpeg,jpg,gif,png ,pneg' but DimensionMin(300,300) is not work....i think custom validation rule is possible ..but i dont know how to use it ?and where ? this is my controller.php code public function getgallery() { $validate=Validator::make(Input::all(),array( 'galname'=>

laravel eloquent query group by last id

不羁的心 提交于 2019-12-20 03:37:11
问题 Hi I'm trying to get the last register in DB for each equipment I got like id | id_equip -----+---------- 1 | 3 2 | 3 3 | 3 4 | 2 5 | 2 I want to query like the last id of each equip like: id | id_equip -----+---------- 3 | 3 5 | 2 I tried this: $calibracao = $this->calibracao->orderBy('id', 'DESC')->groupBy('id_equip')->get(); thanks for the help! 回答1: A simple way , without join , using max : $query = DB::table('equip') ->select(DB::raw('*, max(id) as id')) ->groupBy('id_equip') ->orderBy(

Laravel 4 - How to validate unique with multiple fields?

最后都变了- 提交于 2019-12-20 03:18:05
问题 I have this schema: Schema::create('members', function(Blueprint $table) { $table->increments('id'); $table->string('lname'); $table->string('fname'); $table->integer('mname'); $table->unique(array('lname', 'fname')); }); My problem is, how to validate these unique fields? I tried this but I know this is wrong... public static $rules = array( 'lname' => 'unique:members', 'fname' => 'unique:members' ); Any help is appreciated.. :) 回答1: You should use this package https://github.com/felixkiss

Laravel 4 Auth with Facebook (no password authentication)

人盡茶涼 提交于 2019-12-20 02:57:06
问题 I'm trying to set up an authentication system with Laravel 4 with a Facebook login. I am using the madewithlove/laravel-oauth2 package for Laravel 4. Of course, there is no password to add to my database upon a user loggin in with Facebook. I am, however, trying to check to see if a user id is in the database already to determine if I should create a new entity, or just log in the current one. I would like to use the Auth commands to do this. I have a table called "fans". This is what I'm

Laravel: How to delete rows from multiple table with same id with only 1 query?

半腔热情 提交于 2019-12-20 02:50:10
问题 I have this code to delete data from multiple tables in one go: DB::table('tb_stikes_register_school')->where('register_id', $_POST['id'])->delete(); DB::table('tb_stikes_register_guardian')->where('register_id', $_POST['id'])->delete(); DB::table('tb_stikes_register_student')->where('register_id', $_POST['id'])->delete(); I'm trying to shorten this into 1 query only, register_id from guardian and school tables is the foreign key of student table. I've been trying to use join but only student

Laravel Controller doesn't exist, even though it clearly exists

北城以北 提交于 2019-12-20 02:06:22
问题 The error I'm getting is that the controller doesn't exist even though I know it does, here's the code. Route.php Route::get('mdpay/template', array("uses" => "templateController@index")); templateController.blade.php class templateController extends BaseController { public function index() { echo "made it"; } } Why might I be getting this error: Class TemplateController does not exist ================= UPDATE: ================== Ok, so I've created the correct route, renamed my file, and

PSR-4 autoloading not working

可紊 提交于 2019-12-20 01:41:27
问题 I have created an app/modules directory and autoloaded it using PSR-4 like this: "psr-4": { "Modules\\": "app/modules" } And I also did composer dumpautoload . I have the following directory structure: app - ... - modules -- ModuleName --- controllers ---- BackendController.php ... The file BackendController.php has the namespace Modules\ModuleName\Controllers . And in routes.php , I have the following: Route::resource('backend/modules/module-name', 'Modules\ModuleName\Controllers

User Authentication Across Subdomains on Localhost

烂漫一生 提交于 2019-12-20 01:39:56
问题 I'm building an app on my localhost. When I login via one subdomain, (e.g. sub.localhost/) I need to access that logged-in user with Auth:: in all other subdomains of my application (e.g. sub2.localhost/, sub3.localhost/). I made the change as this post suggests in config/session.php: 'domain' => '.localhost/', No beans. In fact now I can't log in at all. Does this only work with a non-localhost domain? That would suck. 回答1: Did you try with only .localhost instead of .localhost/ if it is

How to get selected radio button value in Laravel

笑着哭i 提交于 2019-12-19 19:48:06
问题 Hi all how to get selected radio button value. I want to store values on my table where selected radio button. My Controller code passing to View $result $result = DB::table('table') ->where('name', $name) ->where('code', $code) ->get(); return View::make('home.search_result') ->with('result', $result); In my view code I had radio button. {{ Form::open(array('action' => 'BookingController@postValue', 'class'=>'well', 'method' => 'GET')) }} <table id="search" class="table table-striped table

Find User in Laravel by Username

大憨熊 提交于 2019-12-19 16:41:35
问题 So typically if you have access to the id of a user in laravel you can run User::find($id), however say you don't have access to the user's id and only their username. Is there a better way than using DB::query to locate the user? This is my current solution and was wondering if someone possibly knew a better way. $user_id = DB::table('users')->where('username', $user_input)->first()->id; 回答1: Yes, even better using the model. just like this User::where('username','John') -> first(); // or