草庐IT

javascript - 从 vue-router 的链接获取 'id' 值

如何从vue-router的链接中获取对象值?例如此链接中的“id”http://laravel.dev/#!/messages/1703因此,使用该ID,我可以从数据库中获取特定数据。我的代码vardetailMessage=Vue.extend({template:'#detailMessage',data:function(){return{id:''}},ready:function(id){this.getID(id);},methods:{getID:function(id){this.$http.get('/api/messages/'+id,function(data)

php - Controller 中的流明(laravel)翻译

我需要翻译在(电子邮件)作业和Controller中使用的字符串。我读到这个:https://laravel.com/docs/5.2/localization所以我知道您可以通过以下方式进入View:echotrans("messages.welcome");但它是一个Lumenapi,我不使用View。我怎样才能让翻译成为一名控制者或一份工作。提前致谢! 最佳答案 要在Controller中获取翻译器,您需要像下面这样使用它//includeinyourcontrolleruseLang;//incodeyougetvalues

php - 保存后的 Laravel 关系可用性()

我正在使用Laravel5构建一个简单的时间跟踪应用程序,其中我有两个Laravel模型,一个称为“用户”,一个称为“周”关系很简单:周.php:publicfunctionuser(){return$this->belongsTo('App\User');}用户.php:functionweeks(){return$this->hasMany('App\Week');}现在,User.php文件还有一个名为“getCurrentWeek()”的简单辅助/新颖函数,顾名思义,它返回当前周functiongetCurrentWeek(){$possibleWeek=$this->week

php - Laravel 5.2 - 方法链接不存在

我正在将我的数组$posts传递到我的View,我正在尝试使用分页,但出现错误:Methodlinksdoesnotexist.(View:C:\xampp\htdocs\app\resources\views\search.blade.php)Controller$posts=Post::where('visible',1)->where('expire_date','>',$current)->where('delete',0);$posts->paginate(1);$posts=$posts->get();returnview('search',compact('posts')

php - 我如何在 laravel 上对对象进行排序?

我的对象数组($c)是这样的:Array([0]=>stdClassObject([id]=>3[name]=>chelsea.png)[1]=>stdClassObject([id]=>4[name]=>arsenal.png)[2]=>stdClassObject([id]=>5[name]=>mu.png)[3]=>stdClassObject([id]=>1[name]=>city.png))我想按id排序如果在php中正常,我会这样尝试:functionsort_by_id($a,$b){if($a->id==$b->id){return0;}return($a->idid)

php - Laravel 5.4,当用户不活动时显示错误消息授权登录

我的重点是如果用户尝试使用有效凭据登录但他的状态字段为0(未激活),则向用户显示一条名为“您处于非事件状态或尚未激活”的错误消息。如果用户的状态为非事件状态,我可以通过LoginController中的以下功能将用户重定向到登录页面。protectedfunctioncredentials(\Illuminate\Http\Request$request){return['email'=>$request->{$this->username()},'password'=>$request->password,'status'=>1];}我如何在Laravel5.4中实现这一点。任何指南

php - 从 View 中的存储文件夹中获取图像 - Laravel 5.4

我试图在我的Laravel5.4profile.blade.php中显示default.jpg头像图片。我在公共(public)文件夹和存储文件夹之间创建了一个链接:phpartisanstorage:link。文件存储:我查看了显示src="/public/storage/uploads/avatar/default.jpg"的网页源代码但是还是找不到图片。有人可以向我解释我所缺少的吗? 最佳答案 从路径中删除public如果您设置正确的链接,图像将显示 关于php-从View中的存储

php - 使用 Laravel Validation 验证 UUID

是否有内置的方法来使用验证规则来验证UUID?我在“AvailableValidationRules”文档中没有找到任何相关信息。 最佳答案 事实上,Laravel5.7支持UUID验证。$validation=$this->validate($request,['uuid_field'=>'uuid']);基于documentation. 关于php-使用LaravelValidation验证UUID,我们在StackOverflow上找到一个类似的问题:

Laravel验证:存在两列同一行

指定Laravel中的验证规则时,是否有一种方法可以引用另一个字段?我的请求:publicfunctionrules(){return['numero_de_somme'=>'unique:personnels,numero_de_somme|exists:fonctionnaire,num_somme','cin'=>'unique:personnels,cin|exists:fonctionnaire,cin',];}在我的验证规则中,我希望能够确保:num_somme存在于其中fonctionnaire桌子cin存在于fonctionnaire表中,cin输入必须在同一行num_somm

php - 使用 Laravel 4 验证多个文件上传

如何在Laravel4中验证上传文件的数组?我已经将它设置为允许多个文件的形式,并且我已经测试了这些文件存在于Input::file('files')数组中。但是我该如何验证每个文件呢?这是我尝试过的:$notesData=array('date'=>Input::get('date'),'files'=>Input::file('files'));//Declaretherulesfortheformvalidation.$rules=array('date'=>'Required|date_format:Y-m-d','files'=>'mimes:jpeg,bmp,png,pdf